A list,

1. Median filtering(1) Concept:(2) Principle explanation: 2 Mean filteringMean filtering refers to the pixel value at any point, which is the mean of N \times M pixel values around it. For example, in the figure below, the pixel value of the red dot is the sum of the pixel values of the surrounding blue background area divided by 25,25 =5\times5 is the size of the blue area.The detailed calculation method of mean filtering is shown in the figure below:The matrix of 5\times5 is called kernel. For pixels in the original image, kernel is used to process and the resulting image is obtained, as shown below: Extracting 1/25 can convert the kernel to the following form:

3 the Lee filter

Two, some source code

clear;
A1=imread('44.jpg')
A=double(A1);
figure(1)
imshow(A/256)
title('Original image');
[a,b]=size(A);

ASp=imnoise(A/256.'speckle'.0.02);
figure(2)
imshow(ASp);
title('Speckle noise image');
% imwrite(ASp/256.'55.jpg'); index_ASp=std2(ASp)/mean2(ASp); Pan Yun, Comparison of Speckle noise filtering Algorithms in Digital Holography ENL=mean2(ASp)^2/std2(ASp)^2; % equivalent visual number PSNR =PSNR(A,ASp); % median filter ME=Medf(ASp,3); % neighborhood3*3
ENL_Me3=mean2(ME)^2/std2(ME)^2; Index_ME3 =std2(ME)/mean2(ME); % speckle index psnr_ME3=PSNR(A,ME); figure(3)
% subplot(2.2.1);
imshow(ME);
title('Median filtered image 3*3');

ME=Medf(ASp,5); % neighborhood ENL_Me5 = mean2 ^ (ME)2/std2(ME)^2; Index_ME5 =std2(ME)/mean2(ME); % speckle index psnr_ME5=PSNR(A,ME); figure(4)
% subplot(2.2.2);
imshow(ME);
title('Median filtered image 5*5');

ME=Medf(ASp,7); % neighborhood ENL_Me7 = mean2 ^ (ME)2/std2(ME)^2; Index_ME7 =std2(ME)/mean2(ME); % speckle index psnr_ME7=PSNR(A,ME); figure(5)
% subplot(2.2.3);
imshow(ME);
title('Median filtered image 7*7');

ME=Medf(ASp,9); % neighborhood ENL_Me9 = mean2 ^ (ME)2/std2(ME)^2; Index_ME9 =std2(ME)/mean2(ME); % speckle index psnr_ME9=PSNR(A,ME); figure(6)
% subplot(2.2.4);
imshow(ME);
title('Median filtered image 9*9'); LE = Leef (% Lee filtering256*ASp,5);
ENL_Lee5=mean2(LE)^2/std2(LE)^2; Index_LE5 =std2(LE)/mean2(LE); % speckle index psnr_LE5=PSNR(A,LE); figure(7)
imshow(LE);
title('Lee filtered image 5*5');

LE=Leef(256*ASp,7);
ENL_Lee7=mean2(LE)^2/std2(LE)^2; Index_LE7 =std2(LE)/mean2(LE); % speckle index psnr_LE7=PSNR(A,LE); figure(8)
imshow(LE);
title('Lee filtered image 7*7');

LE=Leef(256*ASp,9);
ENL_Lee9=mean2(LE)^2/std2(LE)^2; Index_LE9 =std2(LE)/mean2(LE); % speckle index psnr_LE9=PSNR(A,LE); figure(9)
imshow(LE);
title('Lee filtered image 9*9'); Kuan filtering KU % = Kuanf (256*ASp,5);
ENL_Kuan5=mean2(KU)^2/std2(KU)^2; Index_Ku5 =std2(KU)/mean2(KU); % speckle index psnr_Ku5=PSNR(A,KU); figure(10)  
imshow(KU); 
title('Kuan filtered image 5*5');

KU=Kuanf(256*ASp,7);
ENL_Kuan7=mean2(KU)^2/std2(KU)^2; Index_Ku7 =std2(KU)/mean2(KU); % speckle index psnr_Ku7=PSNR(A,KU); figure(11)  
imshow(KU); 
title('Kuan filtered image 7*7');

KU=Kuanf(256*ASp,9);
ENL_Kuan9=mean2(KU)^2/std2(KU)^2; Index_Ku9 =std2(KU)/mean2(KU); % speckle index psnr_Ku9=PSNR(A,KU); figure(12)  
imshow(KU); 
title('Kuan filtered image 9*9'); % mean filter AV=Avef(ASp,3)
ENL_Aver3=mean2(AV)^2/std2(AV)^2; Index_AV3 =std2(AV)/mean2(AV); % speckle index psnr_AV3=PSNR(A,AV); figure(13)  
imshow(AV);
title('Mean filtered image 3*3'); 

AV=Avef(ASp,5)
ENL_Aver5=mean2(AV)^2/std2(AV)^2; Index_AV5 =std2(AV)/mean2(AV); % speckle index psnr_AV5=PSNR(A,AV); figure(14)  
imshow(AV);
title('Mean filtered image 5*5'); 

AV=Avef(ASp,7)
ENL_Aver7=mean2(AV)^2/std2(AV)^2; Index_AV7 =std2(AV)/mean2(AV); % speckle index psnr_AV7=PSNR(A,AV); figure(15)  
imshow(AV);
title('Mean filtered image 7*7'); 

AV=Avef(ASp,9)
ENL_Aver9=mean2(AV)^2/std2(AV)^2; Index_AV9 =std2(AV)/mean2(AV); % speckle index psnr_AV9=PSNR(A,AV); figure(16)  
imshow(AV);
title('Mean filtered image 9*9'); Function [RIL] = Leef(A,N) % Lee filter % A input gray image % RIL output Lee filter gray image Ilee=A; [height,width] = size(Ilee); % height, width: height and width of the image nr =floor(N/2); % N = 2*nr+1; 

Ilee = double(Ilee);
Ilee2 = double(Ilee); % L Visual intensity image L =9; % Visual number delta =1/sqrt(L); % Noise standard deviationfor i = 1:height
    for j = 1:width % Calculate the mean and variance of N*N window sum =0;
        sum2 = 0;
        num = 0;
        for k = -nr:nr
            for m = -nr:nr
                if( (i+k >=1) && (i+k <= height) && (j+m >= 1) && (j+m <= width)) % Avoid array out of bounds num = num +1; sum = sum + Ilee(i+k,j+m); sum2 = sum2 + Ilee(i+k,j+m)*Ilee(i+k,j+m); end end end u = sum/num; % m (fxy) v = sum2/num - u*u; % variance vxy cu=delta/1;
        ci=sqrt(v)/u; % Calculates the value of the center pointif(u == 0)
            k = 0;
        else
             k = (1- cu*cu/(ci*ci)); % Qxy "Research on SAR Image Speckle Noise Suppression Method and Its Application"1-delta/sqrt(v))/(1+delta);
%              k = (v - delta*delta*u*u) / (v + v*delta*delta); 
        end
        
Copy the code

3. Operation results

Fourth, note

Version: 2014 a