What does the operator "~=" mean?

조회 수: 510 (최근 30일)
Linux
Linux 2013년 2월 26일
max2 = @(x) max(max(x));
immax = nlfilter(im, [siz siz], max2);
im(im ~= immax) = 0;
result = im;
This is the code take from a non-maximum suppression function. What does the 3rd line mean? Why can we use "something(something) = 0;" as a statement?
Thank you.
  댓글 수: 1
Image Analyst
Image Analyst 2013년 2월 26일
Why not just us imregionalmax()?

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

채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 2월 26일
something(somthing_else)=0; In MATLAB refers to logical indexing and assignment.
In this case somthing_else has to be logical (think boolean) and
im ~= immax
basically means values where those to are not equal will be true and the rest will be false. When that is followed by:
im(im ~= immax) = 0;
you are equating to zero all the values in im where the above condition is not satisfied.
you will find this information in the documentation under logical indexing.
  댓글 수: 2
Linux
Linux 2013년 2월 26일
Thank you very much.
Paul Metcalf
Paul Metcalf 2013년 2월 26일
Don't feel bad, ~= is one of the first real gotcha's in MATLAB and threw me for a while when I started out. For a long time, I read it as "approximately equal to" rather than "not equal to", quite a fundamental difference. I'm sure there's a big story somewhere about why it's not the standard !=...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by