Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

Frost Filter


Based on the local statistics in a sliding window, the frost filter works on preserving the edges while suppressing the noise. The Damping factor which is an exponential damping is the key factor in controlling the smoothness of the filter. When damping factor is small, the image tends to be smooth.

ALGORITHM:









MATLAB CODE:
%FROST FILTER

%LENNA IMAGE - SPECKLE REDUCTION

% INPUT PARAMETERS - NOISY IMAGE, DAMPING FACTOR, WINDOW SIZE
load('Noise_image1.mat')
ima_nse = double(ima_nse);

%Damping factor
Damp_fact = 1;

%window size
sz = [5,5];

%Preallocate the Output Matrix
ima_fi = zeros(size(ima_nse));
if(mod(sz,2)~=1)
    sz=sz+~mod(sz,2);
end

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

%Padding with zeros around the border
EImg = padarray(ima_nse,mn);


[x,y]= meshgrid(-mn(1,1):mn(1,1),-mn(1,2):mn(1,2));
S = sqrt(x.^2+y.^2);

for i = 1:size(ima_nse,1)
    for j = 1:size(ima_nse,2)
        %Local Window
        K = EImg(i:i+sz(1,1)-1,j:j+sz(1,2)-1);
       
        %Mean value of the pixels in the local window
        meanV = mean(K(:));
       
        %variance of the pixels in the local window
        varV = var(K(:),1);
       
        %Weight for each pixel in the local window
        B =  Damp_fact*(varV/(meanV*meanV));
        Weigh = exp(-S.*B);
       
        % Filtering
        ima_fi(i,j) = sum(K(:).*Weigh(:))./sum(Weigh(:));
       
    end
end

figure,subplot(121),imagesc(ima_nse);colormap(gray);title('Original Image');
subplot(122),imagesc(ima_fi);colormap(gray);title('After Despeckling - Frost Filter');





EXPLANATION:
Here in the example given above, the damping factor = 1 and the size is 5x5.

Let’s consider another example, where damping factor =1 and the local window size is 11x11
The image becomes smooth as well as the edges.


This is the parameter, S that has the distance from centre of the pixel to its neighbours in the local window. See that the distance at the centre for the centre pixel is zero, while the distance from the centre to the adjacent pixel is 1 and the increase in value based on the distance between the pixels is evident in the figure.


While in this example, where damping factor = 3 and the local window size is 11x11, the edges are preserved. By controlling the damping factor, a trade-off between the smoothness and preservation of the edges can be done.



like button Like "IMAGE PROCESSING" page

0 comments:

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Google ping Hypersmash.com