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

Home » Public Forums » archive » Re: inverting a binary image(array)?
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: inverting a binary image(array)? [message #78279] Mon, 07 November 2011 11:58
desertdryad is currently offline  desertdryad
Messages: 39
Registered: August 2011
Member
David - 'invert' as in, 0's become 1's, and vice-versa.

On Nov 7, 1:00 am, "M. Katz" <MKatz...@yahoo.com> wrote:
> In my quick tests,
>   a = ~temporary(a)

Say, thanks! I tried this, and it works right quick.
Re: inverting a binary image(array)? [message #78284 is a reply to message #78279] Mon, 07 November 2011 00:00 Go to previous message
M. Katz is currently offline  M. Katz
Messages: 69
Registered: May 2005
Member
In my quick tests,
a = ~temporary(a)
seems to have the same speed as
a = 1b - temporary(a)
Re: inverting a binary image(array)? [message #78285 is a reply to message #78284] Sun, 06 November 2011 07:24 Go to previous message
Jim  Pendleton is currently offline  Jim Pendleton
Messages: 165
Registered: November 2011
Senior Member
On Nov 4, 3:54 pm, desertdryad <dry...@gmail.com> wrote:
> What's the most streamlined way to do this?

In the ENVI environment, you might consider writing a simple band math
user function.

Look for the "Band and Spectral" math section of the ENVI Programmer's
Guide in the online help.

You'll then have a function you can reuse in other contexts within
ENVI.

ENVI will tile the data as necessary so if the image is very large you
won't exhaust memory.

For extra points, use the TEMPORARY function and use the same data
type as the input band to prevent upcasting and unnecessary data
copying, (e.g., for byte data: RETURN, 1B - TEMPORARY(b1), for
unsigned short data: RETURN, 1US - TEMPORARY(b1)).

Social media alert: I work for Exelis VIS, but any implied or
expressed opinions are my own.
Re: inverting a binary image(array)? [message #78286 is a reply to message #78285] Sat, 05 November 2011 21:29 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 11/4/11 6:54 PM, desertdryad wrote:
> Hi folks -
>
> I have the need, in an IDL 7.0 / ENVI 4.5 script, to take a rather
> large raster (Landsat tile sized) of 1's and 0's, and invert it, in
> preferably an efficient manner. What's the most streamlined way to do
> this?
>
> thanks,
> Cyndy
>

If by "invert" you mean turn the 1s to 0s and the 0s to 1s, I would
hazard a guess that you're not going to get much more efficient than

data = 1 - data

-Jeremy.
Re: inverting a binary image(array)? [message #78290 is a reply to message #78286] Fri, 04 November 2011 16:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
desertdryad writes:

> I have the need, in an IDL 7.0 / ENVI 4.5 script, to take a rather
> large raster (Landsat tile sized) of 1's and 0's, and invert it, in
> preferably an efficient manner. What's the most streamlined way to do
> this?

What does "invert" mean in this context?

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL 8.1, X11 and Crashes
Next Topic: Re: Overlaying multiple plots on top of map

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

Current Time: Wed Oct 08 15:27:00 PDT 2025

Total time taken to generate the page: 0.00546 seconds