Replacing centre pixel value

조회 수: 1 (최근 30일)
FIR
FIR 2012년 12월 19일
I have a code ,of 7x7 natrix in that for each 3x3 i have found minimum value and if that minimum value is greater the centre pixel value ,the centre pixel value must be replaced by 5.have problem in replacing centre pixel value ,please help
for i=2:6
for j=2:6
K= A(i-1:i+1,j-1:j+1);
T=K(2,2);finding centre pixel value
B=min(K(:));
if B>T
%%%please tell what must come here replacing centre pixel vaue by 5
%%%%I DID K(2,2)=5;
else
%%%%%%%%%here also
%%I DID K=K;
end
end
end
BUT I GET 3x3 matrix only,how to get 7x7 matrix
please assist
please assist
  댓글 수: 1
Image Analyst
Image Analyst 2012년 12월 19일
You've been posting here long enough that you should already know how to format your questions. Please review the tutorial http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup. By the way, you can type Ctrl-A, Ctrl-I, Ctrl-C when your code is in MATLAB to fix indenting problems. Then come here and paste it in, highlight it, and click {}Code. Do not have any spaces before non-code text (like your first paragraph). It's not hard - give it a try.

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

답변 (2개)

Image Analyst
Image Analyst 2012년 12월 19일
The minimum value in a 7x7 window will never be greater than the center value. Please explain what you are thinking.
By the way, you can call imerode() to get the local min values in a 7x7 sliding window.
  댓글 수: 3
Image Analyst
Image Analyst 2012년 12월 19일
편집: Image Analyst 2012년 12월 19일
But the concept is flawed! Anyway, you might play around and use imerode and subtract it from your original, or vice-versa. Then threshold and replace items meeting the threshold with 5. I think you already know how to do that without loops. Even if you did want to use loops, you'd have to have 4 loops, not 2. Two to scan rows and columns, and then at each pixel, another two loops (like you already have) to scan a window around that pixel. But not a very efficient way to do it. I suggest you review the code examples I gave you in your prior, related questions.
FIR
FIR 2012년 12월 20일
Can u please post an example here please,i could nor review the codes since there are many questions posted by me

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


Walter Roberson
Walter Roberson 2012년 12월 19일
  댓글 수: 6
FIR
FIR 2012년 12월 20일
ok walter thanks
can u guide me in quanterion switching filter,please
Walter Roberson
Walter Roberson 2012년 12월 20일
I do not know anything about quaternion switching filters.

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by