how could i turn this into a 5 by 5 filter

2 views (last 30 days)
I= imread('peppers.png');
I2=I;
[r, c,]=size(I);
for i = 2:r-1
for j = 2: c-1
uint8=[I(i-1,j-1),I(i-1,j),I(i-1,j+1),I(i,j-1),I(i,j),I(i,j+1),...
I(i+1,j-1),I(i+1,j),I(i+1,j+1)];
uint8=sort(uint8);
I2(i,j)= uint8(5);
end
end
figure;
imshow(I);
title('peppers noisy');
figure;
imshow(I2);
title('peppers');
  2 Comments
Lewis Laurence
Lewis Laurence on 23 Jan 2022
thank you for your comments. Im just struggling on how I would implement this.

Sign in to comment.

Answers (1)

Matt J
Matt J on 23 Jan 2022
Edited: Matt J on 23 Jan 2022
I2=medfilt2(I,[5,5]);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by