how could i turn this into a 5 by 5 filter

조회 수: 4 (최근 30일)
Lewis Laurence
Lewis Laurence 2022년 1월 23일
댓글: Lewis Laurence 2022년 1월 23일
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
DGM
DGM 2022년 1월 23일
편집: DGM 2022년 1월 23일
The last comment I left on your other question implements a 5x5 median filter. The filter size is adjustable.
I also included a link to a second example of an adjustable (example shows 5x5) size median filter using a slightly different approach.
Note that in this version of your code, you're shadowing the built-in function uint8() by using that as a variable name.
Lewis Laurence
Lewis Laurence 2022년 1월 23일
thank you for your comments. Im just struggling on how I would implement this.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2022년 1월 23일
편집: Matt J 2022년 1월 23일
I2=medfilt2(I,[5,5]);

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by