help to identify the mistake
Mostrar comentarios más antiguos
code doe median filter.i am no able to get the final filtered output image.plz help me to rectify the mistake
clc
clear all
close all
i=imread('peacock.jpg');
imshow(i);
i=imnoise(i,'salt & pepper',0.05);
figure,imshow(i)
p=input('Enter the size of kernel of median filter, (n for nxn matrix):');
pad=uint8(zeros(size(i)+2*(p-1)));
%loop for padding the zeros
for x=1:size(i,1)
for y=1:size(i,2)
pad(x+p-1,y+p-1)=i(x,y);
end
end
%loop for finding the median & replacing the central pixel
for i= 1:size(pad,1)-(p-1)
for j=1:size(pad,2)-(p-1)
kernel=uint8(ones((p-1)^2,1));
t=1;
for x=1:p-1
for y=1:p-1
kernel(t)=pad(i+x-1,j+y-1);
t=t+1;
end
end
filt=sort(kernel);
out(i,j)=filt(5);
end
end
figure,imshow(out); %show the final recovered image
1 comentario
Ameer Hamza
el 21 de Abr. de 2020
What is the issue? Do you get any error?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Segmentation and Analysis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
