I’m trying to obtain the values between two relational operation from an image.
A(34,67,4) is an image with the given values.
I need the values of A between 0 and 16 (0<=A<=16).
When I tried to do it as follows, this just gave me 0 or 1 (not values of A array). Could you tell me What the problem is?
B=((A<=0)&(A>=16)+((A>=0)&(A<=16))
You want to apply the condition
as logical indexing on the matrix
A:This’ll render you a vector of values, because it selects only those values that satisfy your condition, and because they can occur anywhere in the matrix, there is no structure to return them to you but in a vector.
If you however want to keep the matrix, and reset every value that does not satisfy the condition the 0 or
NaN(so everything that’s left is all the elements that do satisfy the condition) use the following:If you also want to apply an operation to those values (and those values only, not the NaN’s), you can do it as follows:
For example:
It’ll set all values outside the range 0-16 to NaN, and apply the floor function on all values inside the range.