comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34741] Sat, 12 April 2003 08:25
rmoss4 is currently offline  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 #34742 is a reply to message #34741] Sat, 12 April 2003 02:21 Go to previous message
cshen is currently offline  cshen
Messages: 6
Registered: April 2003
Junior Member
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 #34743 is a reply to message #34742] Fri, 11 April 2003 20:29 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Robert Moss (rmoss4@houston.rr.com) writes:

> That's what it is. Trust me on this. Here's an example:

I'm coming late to this. Have we already placed
bets. I've got $5 on Robert!

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
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 Go to previous message
rmoss4 is currently offline  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 Go to previous message
rmoss4 is currently offline  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 #34746 is a reply to message #34745] Fri, 11 April 2003 17:59 Go to previous message
cshen is currently offline  cshen
Messages: 6
Registered: April 2003
Junior Member
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 #34750 is a reply to message #34746] Fri, 11 April 2003 07:10 Go to previous message
rmoss4 is currently offline  rmoss4
Messages: 21
Registered: October 2002
Junior Member
I'd say that's the problem. Try converting the data to integer and see
how it looks.

Robert Moss, PhD

xinhai68 wrote:
> 0-255
>
> Thanks
Re: ENVI band math: "b1 gt b2 " , "(b1-b2) gt 0" same or not? [message #34751 is a reply to message #34750] Thu, 10 April 2003 22:48 Go to previous message
cshen is currently offline  cshen
Messages: 6
Registered: April 2003
Junior Member
0-255

Thanks
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 Go to previous message
rmoss4 is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Floating point error
Next Topic: Re: IDL objected oriented question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:53:45 PDT 2025

Total time taken to generate the page: 0.00396 seconds