14 views

Uploaded by Laura Pamela Alvarez

Lee Filter

- f4rgser
- Payroll Costing
- Python Quick Reference
- Resume Nilesh
- 1 Honey Well Technical Paper 2
- c_basics
- appropriate - pisey men
- Android exam sample questions UTS
- Abstract
- Hcl7
- Freshersworld_com3
- basic - all_excel_function.pdf
- C FAQs
- COCI contest 4 solutions
- lect15
- 2 Semester
- Bjarne Stroustrup
- amdocs prev papers
- List of Programs12 2012 13
- Embedded c

You are on page 1of 8

IMAGE PROCESSING

Lets Learn together... Happy Reading FOLLOW US

Follow @AaronAngel_

" Two roads diverged in a wood, and I,

I took the one less traveled by,

And that has made all the difference "-Robert Frost Search This Blog

Search

Lee filter

Since it’s a patch based processing, the computation cost will be high.

In order to reduce the same, a part of the code is realized in C language for improved performance.

MATLAB code: topic

%Read an Image Denoising

I = imread('coins.png'); Biomedical Imaging

%Add multiplicative noise to the image Image Segmentation

J = imnoise(I,'speckle',0.01); Multiresolution processin

Machine Learning

Remote Sensing

Compression Techniques

Poll closed

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 1/8

30/1/2018 Lee filter | IMAGE PROCESSING

GIFT TODAY

Featured Post

%Apply Lee filter Python

K = Lee_filter_C(I,J,[5 5]);

Python is a high level

figure,imshow(uint8(K));

programming language which has

easy to code syntax and offers

packages for wide range of

applications including nu...

Image Processing

7,726 likes

This function takes the reference image, speckled/noisy image and the window size as input and Like Page

Be the first of your friends to like this

1. The variance of the reference image is found. Variance can be found either by using MATLAB built-in

function or user defined function. Here in this case, a user defined function is used to find the variance.

2. Based on the size of the kernel, the noisy image is padded with zeros on all sides.

3. The center index of the kernel is found

LIKE "IMAGE

4. The noisy image is processed patch by patch. PROCESSING"

5. The code written in C computelee.c to despeckle the image is used. Support this blog by leaving

your valuable comments and a

like on Facebook Fan Page.

THANKS FOR READING

MATLAB code:

function Y = Lee_filter_C(R,E,sz)

%R is the Reference Image ADD ME

%E is the Error or Noisy Image

%K is the Kernel or Window IMAGE PROCES

%Y is the Output Image

Follow

% Y = mean(K)+W*(C-mean(K);

% W = variance(K)/(variance(K)+variance(R))

R = double(R); Subscribe Now:

E = double(E);

Subscribe in a reader

%Preallocate the Output Matrix

Y = zeros(size(R));

mn = round((sz-1)/2);

Tot = sz(1,1)*sz(1,2);

EImg = padarray(E,mn);

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 2/8

30/1/2018 Lee filter | IMAGE PROCESSING

Rvar = myvar(R);

%Rvar = var(R(:));

Indx = floor(median(1:Tot));

TAGS

for i = 1:size(R,1)

for j = 1:size(R,2) Removing Image

K = EImg(i:i+sz(1,1)-1,j:j+sz(1,2)-1); noise GUI

Y(i,j) = computelee(Rvar,K(Indx),K(:)'); Components in

MATLAB Image

end Conversion Edge detection

end Photoshop effects in

MATLAB MATLAB

BUILT_IN FUNCTIONS

end Morphological Image Processing

Video Processing Array functions

in MATLAB Files Histogram

NOTE: save the above function as Lee_filter_C.m equalization Image Compression

Object Identification Optical

Function to find the variance: illusion Shapes Templates Image

MATLAB code: Geometry Image Arithmetic

I = I(:); Followers

var_v = sum((I-mean(I)).^2)/numel(I);

end Seguidores (107) Siguiente

C program: computelee.c

If you are familiar with C programming then we just need to understand the gateway from MATLAB to

C programming. The rest of the procedures will be same as we code in c.

The main gateway function for writing the C program is Mex function and it normally takes 4

parameters. Seguir

Plhs – Contains all the output parameters in an array

C code:

#include "mex.h"

void arrayProduct(double v, double In, double *y, double *z, mwSize n)

{

double VarW,MeanW,W;

mwSize i;

MeanW=0;

for (i=0; i

MeanW=MeanW+y[i];

}

MeanW=MeanW/n;

VarW=0;

for(i=0;i

{

VarW=VarW+((y[i]-MeanW)*(y[i]-MeanW));

}

VarW=VarW/n;

W=VarW/(VarW+v);

z[0]=MeanW+W*(In-MeanW);

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 3/8

30/1/2018 Lee filter | IMAGE PROCESSING

}

int nrhs, const mxArray *prhs[])

{

double Rvariance,CIndx,*inMatrix,*out;

size_t ncols;

Rvariance = mxGetScalar(prhs[0]);

CIndx = mxGetScalar(prhs[1]);

inMatrix = mxGetPr(prhs[2]);

ncols = mxGetN(prhs[2]);

out = mxGetPr(plhs[0]);

arrayProduct(Rvariance,CIndx,inMatrix,out,(mwSize)ncols);

}

Let’s compare the calling function in MATLAB and the C code for better understanding.

MATLAB code:

computelee(Rvar,K(Indx),K(:)');

1. Variance of the reference image

2. Centre pixel from the kernel

3. All the pixels from the kernel based on the window size

C code:

Rvariance = mxGetScalar(prhs[0]);

CIndx = mxGetScalar(prhs[1]);

inMatrix = mxGetPr(prhs[2]);

CIndx contains the centre pixel of the corresponding kernel/patch

inMatrix contains all the pixels of the corresponding kernel/patch

ncols = mxGetN(prhs[2]);

out = mxGetPr(plhs[0]);

Steps to be performed:

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 4/8

30/1/2018 Lee filter | IMAGE PROCESSING

Let’s see how Lee filter works on homogeneous area and edge based area.

Homogeneous Patch

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 5/8

30/1/2018 Lee filter | IMAGE PROCESSING

The result shows that the filter works well on homogeneous area rather than on edges and lines.

1. If you are using the C code for the first time, its better to find the appropriate compiler and configure to

use it.

2. Compile the C code if the compiler is already present and make sure the compilation is successful.

3. Syntax to setup the compiler: mex - setup

The above syntax will identify the available compilers in your local system and you can configure it

manually.

4. For compiling the above c code: mex computelee.c

For successful compilation, the sample output will look like below:

Building with 'lcc-win32'.

MEX completed successfully.

5. The result of successful compilation will generate computelee.mexw32 for 32 bit system and for 64 bit

system, you can find computelee.mexw64 file in your local directory.

To sum up, the two functions Lee_filter_C.m and myvar.m should be placed in the same directory.

Computelee.c should also be placed in the same directory and the successful compilation of the same is

mandatory.

I hope the readers of my blog will be familiar with working on Mex files. If you need any tutorial or post

on this topic, kindly post or mail your suggestions.

Your Reactions: Useful (0) Interesting (0) Not bad (0) :-( (0)

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 6/8

30/1/2018 Lee filter | IMAGE PROCESSING

4 comments:

Sun flower said...

very nice blog http://www.softql.com/

December 24, 2014 at 4:09 PM

really nice blog.

E2matrix

January 20, 2015 at 5:21 PM

saikrishna k said...

how to convert cmexfile to matalab code sir

March 18, 2015 at 1:13 PM

what if you do not know the variance of the original data

May 19, 2017 at 2:17 AM

Gaussian Filter Gaussian Filter is used to blur the image. It is used to reduce the noise and the image details. ...

Lets see how to detect face, nose, mouth and eyes using the MATLAB built-in class

and function. Based on...

Find Area, Perimeter, Centroid, Equivdiameter, Roundness and Bounding Box without Using MATLAB Function ‘regionprops’

In MATLAB, the function ‘regionprops’ is used to measure the image properties. Here are some basic properties computed

without using the ...

To perform the thresholding I followed these steps: a. Reshape the 2 dimensional grayscale

image to 1 dimens...

Prerequisite: Read EdgeDetection- fundamentals The derivative operator Laplacian for an Image is defined as For X-

dire...

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 7/8

30/1/2018 Lee filter | IMAGE PROCESSING

Powered by Blogger.

3015839

https://angeljohnsy.blogspot.com/2014/08/lee-filter.html 8/8

- f4rgserUploaded byabhishek
- Payroll CostingUploaded bysowball
- Python Quick ReferenceUploaded byHélène Martin
- Resume NileshUploaded byShyam Singh
- 1 Honey Well Technical Paper 2Uploaded byVishal Kumar
- c_basicsUploaded bySanthosh Nandakumar
- appropriate - pisey menUploaded byapi-209124933
- Android exam sample questions UTSUploaded byturok_gt
- AbstractUploaded byVenu Gopal
- Hcl7Uploaded byinnovatorinnovator
- Freshersworld_com3Uploaded byrrl5050
- basic - all_excel_function.pdfUploaded bysam_ganda
- C FAQsUploaded byivyzengoh
- COCI contest 4 solutionsUploaded byธนโชติ ไม่บอกหรอก
- lect15Uploaded byShohagh Shosagh
- 2 SemesterUploaded bysufisafia
- Bjarne StroustrupUploaded byLavanya
- amdocs prev papersUploaded bysiddhu1711
- List of Programs12 2012 13Uploaded bynita23arora2321
- Embedded cUploaded byMohammed El-Adawy
- rtrt-refUploaded bypouet9348
- ConvertingUploaded bybmorris2
- C Programming(brief notes)Uploaded byBrandon
- pldi2005hfhUploaded byStavros
- Turbo C User' GuideUploaded byPedro Bortot
- Introduction to Pro_CUploaded byssray23
- Computer ProgrammingUploaded byKishor Peddi
- Line algorithmUploaded byVibhor Bhardwaj
- 5th_Ed_Ch02_QCUploaded bymohan
- Java Multiple Choice QuestionsUploaded byAshish Agarwal

- 2010 SismicaSomera InnomarSES SenalmarUploaded byLaura Pamela Alvarez
- A9Uploaded byLaura Pamela Alvarez
- Matlab SignalUploaded byPanagiotis Giannoulis
- 03-electrica.pdfUploaded bymjailovi
- Sonar Processing Project nUploaded byoman13905
- Sonar Processing Project nUploaded byoman13905
- 6 PipelineUploaded byLuis Oswaldo Velasquez Lovera
- Series Numericas Otono Ficha 1Uploaded byLaura Pamela Alvarez
- Tarea1Uploaded byLaura Pamela Alvarez
- Tarea Log BayesUploaded byLaura Pamela Alvarez
- Ruido.pdfUploaded byAlberto Jimenez
- WienerUploaded byLaura Pamela Alvarez
- Pre PrintUploaded byLaura Pamela Alvarez
- Procesamiento digital de imágenes usando wavelets.pdfUploaded byT1J427
- SpectrogramUploaded byLinh Nguyen
- GEO054Uploaded byLaura Pamela Alvarez
- Alg Lin II Prac1Uploaded by77jacki77
- Secuencia DorUploaded byLaura Pamela Alvarez
- Tema 2.Modelos de ColorUploaded byLaura Pamela Alvarez
- TamUploaded byLaura Pamela Alvarez
- ProyectoNo3_ Ecualizacion de Distancia de HistogramaUploaded byLaura Pamela Alvarez
- filtros_analogicosUploaded byhgabzv
- Manual Tecnicas[1]Uploaded byRicardo Buendia Sierra
- tesina_MTF.pdfUploaded byLaura Pamela Alvarez
- 1 Introduction to FractalUploaded byupildekil
- diseo_de_procesadores.pdfUploaded byLaura Pamela Alvarez
- HydroacousticsUploaded byKevinPereyra
- Copia de Capitulo 2 Ejercicio 2 y 7Uploaded byLaura Pamela Alvarez
- Anisotropic DiffusionUploaded bymisdyle

- Z80 Assembly Language Programming 1979 LeventhalUploaded byVanessa Stacy
- final-Trust-Services.pdfUploaded byMasdarR.MochJetrezz
- Cisco Report ModifiedUploaded byshan
- Copy of Copy of Pokémon Go IV Calculator.pdfUploaded bySeth Revelo
- Servlets FinalUploaded byyashhhhhhh
- Multimedia in Embedded Linux GuideUploaded bydenkins2020
- WORDoLE.txtUploaded bygaurav
- FusionCloud Desktop V100R005C30 Software Installation Guide 05Uploaded byAlvaro Andres Ponce Norambuena
- TSC TDP-247 Direct Thermal Label Printer BrochureUploaded byJohnny Barcode
- An Investigation Into Android Run-time Permissions From the End Users’ PerspectiveUploaded byJexia
- HomeHealthTechnology-A20BillionDollarIndustryHandoutsUploaded byAnne Marie Grady
- AC53_Configuration_Guide.pdfUploaded byKaushik Bose
- SM60Cisco7960CMUploaded bymw132201
- Kratos2Maximizer EULAUploaded byjack
- FortiSwitch and Security Fabric v2_Public.pdfUploaded byDJ JAM
- USB - Obtaining a WHQL Certified USB Driver PackageUploaded byPatricio Llerena
- JPS Documentation/WikiUploaded byMayank Sharma
- INFS1609 Fundamental of Business Programming S22012Uploaded byThu Hà Trương
- MariaDB Database Administration Training 5 Day Course Outline(2)Uploaded byDSunte Wilson
- 2019 Security-Awareness-checklist Okt 2018Uploaded byEnis Basagic
- 710598_3_Polycom_HDX_Configuration_Guide_for_8x8_Service.pdfUploaded bytheanhcb
- Westlaw Student Handout Spring09Uploaded byNCCLibrarian
- WFA_PPTUploaded byMuthu Kumaran Loganathan
- 112233qwe444Uploaded byMuhamad Richard Menarizki
- Creating an Inverter Layout Using L-EditUploaded byrakheep123
- Google Security Whitepaper _ DocumentationUploaded byMainak Hore
- cybercrimeUploaded byapi-256872472
- Graph Algorithm for Software Model ChekingUploaded byLuki Bangun Subekti
- ZXWM M920 Product DescriptionUploaded byxiway
- Final Test 22222Uploaded bybigmamun