threshold values

조회 수: 8 (최근 30일)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2012년 5월 22일
답변: Neesha Sahl 2019년 4월 3일
My threshold value=0.9
If the pixel value is less than 0.9, I have to set it to zero...
else set it to 255.
What command should be used for this

답변 (4개)

the cyclist
the cyclist 2012년 5월 22일
Does this do what you want?
p = 255*(p>=0.9);
  댓글 수: 3
Image Analyst
Image Analyst 2012년 5월 22일
Assuming p is your image array, it does match your requirement. If it doesn't you need to say why not, because then there would be something you didn't tell us. In your original question you did NOT say anything about "finding" a threshold value - you said that it was 0.9.
Geoff
Geoff 2012년 5월 22일
+1 : this does exactly what you have requested, but you might not understand why. The call (p>=0.9) returns an array of 0 or 1: 0 if the value is less than 0.9 and 1 otherwise. By multiplying by 255, this achieves your two tasks (set to zero or set to 255) simultaneously. Did you actually try it?

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


Ricky
Ricky 2012년 5월 22일
you could try this:
p = 255;
i = find(p < 0.9);
p(i) = 0;
  댓글 수: 1
Geoff
Geoff 2012년 5월 22일
This code will turn the image into a single value (255), and then do a find which will fail, rendering the last two lines of code pointless.

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


Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2012년 5월 30일
Hi, Thanks all for guiding me

Neesha Sahl
Neesha Sahl 2019년 4월 3일
Can someone explain to me threshold values in simple English? Such as why I need to set a threshold value when I am running Optical Flow and how to pick the best threshold value.

카테고리

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