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

Home » Public Forums » archive » Re: rejecting a few pixel values from an array of pixel values
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: rejecting a few pixel values from an array of pixel values [message #70077] Sat, 13 March 2010 07:55
Robert Moss, PhD is currently offline  Robert Moss, PhD
Messages: 29
Registered: November 2006
Junior Member
On Mar 13, 10:01 am, sid <gunvicsi...@gmail.com> wrote:
> Hi,
>    I am having an image array with 1024*1024 pixel values with pixel
> values ranging from 1.39 to 0.03. Now I need only pixel values ranging
> from 1.1 to 0.8, so please do suggest me what method to follow to get
> only the pixel values of my interest, also suggest if any looping can
> be done for this kind of job.
> regards
> sid

No looping is required. Briefly you probably want the WHERE function
or the HISTOGRAM function, depending on what you plan on doing. As an
example (by no means intended to be the most clever or shortest) you
could do the following:

;; Assume zero can be used as missing data
;; mask the data over 1.1
hi = WHERE( image GT 1.1, nhi )
IF nhi GT 0 THEN image[ hi ] = 0
;; mask the data less than 0.8
lo = WHERE( image LT 0.8, nlo )
IF nlo GT 0 THEN image[ lo ] = 0

;;at this point only pixels in image that are non-zero are between 0.1
and 1.1 inclusive

If you just want statistics on those pixels, skip all that and use
histogram
h = HISTOGRAM( image, MIN = 0.8, MAX = 1.1, BINSIZE = 0.01 )

r
Re: rejecting a few pixel values from an array of pixel values [message #70078 is a reply to message #70077] Sat, 13 March 2010 07:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
sid writes:

> I am having an image array with 1024*1024 pixel values with pixel
> values ranging from 1.39 to 0.03. Now I need only pixel values ranging
> from 1.1 to 0.8, so please do suggest me what method to follow to get
> only the pixel values of my interest, also suggest if any looping can
> be done for this kind of job.

I take it you are new to IDL. :-)

Here is a suggestion. Don't write loops in IDL. You
can find the image values you want like this:

indices = Where(image GE 0.8 AND image LE 1.1, count)
IF count GT 0 THEN valuesOfInterest = image[indices]

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.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: re-create a widget
Next Topic: Re: how to display on the unix system

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

Current Time: Fri Oct 10 12:06:34 PDT 2025

Total time taken to generate the page: 1.27944 seconds