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

Min Filter - MATLAB CODE

MIN FILTER
  •      To find the darkest points in an image.
  •       Finds the minimum value in the area encompassed by the filter.
  •       Reduces the salt noise as a result of the min operation.
  •       The 0th percentile filter is min filter.

MATLAB CODE:

%READ AN IMAGE
A = imread('board.tif');
A = rgb2gray(A(1:300,1:300,:));
figure,imshow(A),title('ORIGINAL IMAGE');

%PREALLOCATE THE OUTPUT MATRIX
B=zeros(size(A));

%PAD THE MATRIX A WITH ZEROS
modifyA=padarray(A,[1 1]);

        x=[1:3]';
        y=[1:3]';
       
for i= 1:size(modifyA,1)-2
    for j=1:size(modifyA,2)-2
      
       %VECTORIZED METHOD 
       window=reshape(modifyA(i+x-1,j+y-1),[],1);

       %FIND THE MINIMUM VALUE IN THE SELECTED WINDOW
        B(i,j)=min(window);

    end
end

%CONVERT THE OUTPUT MATRIX TO 0-255 RANGE IMAGE TYPE
B=uint8(B);
figure,imshow(B),title('IMAGE AFTER MIN FILTERING');












like button Like "IMAGE PROCESSING" page

1 comments:

Jack said... Reply to comment

What is the meaning of -2 in for loop

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Google ping Hypersmash.com