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

Max Filter - MATLAB CODE

  • To find the brightest points in an image.
  •  Finds the maximum value in the area encompassed by the filter.
  •  Reduces the pepper noise as a result of the max operation.
  •  The 100th percentile filter is max filter. Check the 50th percentile filter i.e the median 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 MAXIMUM VALUE IN THE SELECTED WINDOW
        
       B(i,j)=max(window);
   
    end
end

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














like button Like "IMAGE PROCESSING" page

3 comments:

Unknown said... Reply to comment

Excellent Blog.... (Y) (Y) (Y)

Unknown said... Reply to comment

Index exceeds matrix dimensions.

Error in max (line 3)
A = rgb2gray(A(1:300,1:300,:)); this will shows when i am going to try different image...please help as soon as

ravi said... Reply to comment

for x=1:size(my_image,1)
for y=1:size(my_image,2)

Enjoyed Reading? Share Your Views

Previous Post Next Post Home
Google ping Hypersmash.com