Search This Blog

Max Filtering in Image Processing using Matlab with code

A nonlinear
the filter is obtained by a non-linear function of the grayscale values in the mask. Simple examples are the maximum filter, which has as its output the maximum value under the mask, and the corresponding minimum filter, which has as its output the minimum value under the mask.

%Max Filter Code:

 

clc

clear all

close all

warning off

k=imread('G:\Documents\MATLAB\Examples\2020\07_July\bird.jpg');

figure;

imshow(k);

title('Input Image');

x=rand(size(k));

k(x(:)<0.05)=0;

figure;

imshow(k);

sto=[];

[a b]=size(k);

output=zeros(a,b);

for i=2:a-1

    for j=2:b-1

        sto=[k(i-1,j-1),k(i-1,j),k(i-1,j+1),k(i,j-1),k(i,j)...

            ,k(i,j+1),k(i+1,j-1),k(i+1,j),k(i+1,j+1)];

        es=max(sto);

            output(i,j)=es;

        sto=[];

    end

end

figure;

imshow(uint8(output));

 

 








 


No comments