Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34741] |
Sat, 12 April 2003 08:25 |
rmoss4
Messages: 21 Registered: October 2002
|
Junior Member |
|
|
Convert your image to integer type (or floating point, depending on
exactly what you are doing to it). Yes, it will cost you storage space.
Using band math, you could use the expression
( ( fix( b1 ) - fix( b2 ) ) gt 0 )
This will produce the expected results.
Robert Moss, PhD
xinhai68 wrote:
> Thanks all. Now I understand what happened. But, could you enlighten
> me how to solve the problem? I want to use the format of "(b1 - b2) gt
> 0" because my real expression would be much complicated and I want to
> put variables on same side.
|
|
|
|
|
Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34744 is a reply to message #34743] |
Fri, 11 April 2003 20:02  |
rmoss4
Messages: 21 Registered: October 2002
|
Junior Member |
|
|
Um, that should have been
( b1 - b2 ) gt 0 = 1B i.e. ( b1 - b2 ) = -1 = 255B > 0 = 1
Nevertheless, the point is the same: it is the byte arithmetic that is
causing your confusion.
R
Robert Moss wrote:
> That's what it is. Trust me on this. Here's an example:
>
> Take a single pixel in each band, i.e.
>
> b1 = 17B
> b2 = 18B
>
> Remember, these are both bytes.
>
> Then you get
>
> ( b1 gt b2 ) = 0B
> ( b1 - b2 ) gt 0 = 255B ( b1 - b2 ) = -1 = 255B > 0
>
> Robert Moss, PhD
>
>
>
> xinhai68 wrote:
>
>> I do not think so. You could try using ENVI's self-contained example
>> bhtmref.img to do "b1 gt b2" and "(b1-b2)gt 0" to see the different
>> result.
>
>
|
|
|
Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34745 is a reply to message #34744] |
Fri, 11 April 2003 19:59  |
rmoss4
Messages: 21 Registered: October 2002
|
Junior Member |
|
|
That's what it is. Trust me on this. Here's an example:
Take a single pixel in each band, i.e.
b1 = 17B
b2 = 18B
Remember, these are both bytes.
Then you get
( b1 gt b2 ) = 0B
( b1 - b2 ) gt 0 = 255B ( b1 - b2 ) = -1 = 255B > 0
Robert Moss, PhD
xinhai68 wrote:
> I do not think so. You could try using ENVI's self-contained example
> bhtmref.img to do "b1 gt b2" and "(b1-b2)gt 0" to see the different
> result.
|
|
|
|
|
|
Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34755 is a reply to message #34751] |
Thu, 10 April 2003 19:19  |
rmoss4
Messages: 21 Registered: October 2002
|
Junior Member |
|
|
It sounds like you might be having a problem because of byte arithmetic.
What is the data type of you imagery?
Robert Moss, PhD
xinhai68 wrote:
> I have a strange problem. I often used band math to generate mask,
> such as "b1 gt 0" will give me 1 to all points which satisfies the
> condition. But now I want to find all points that b1>b2, I meet
> unexpected result. If I use "b1 gt b2", I get the correct answer. If I
> use "(b1 - b2) gt 0", ENVI will also return a result, but I can not
> guess what ENVI is doing because the result is weird. Can anyone tell
> me what happened? Thanks
|
|
|