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

Home » Public Forums » archive » Re: Quick question regarding "where" function
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: Quick question regarding "where" function [message #45825] Wed, 12 October 2005 14:41 Go to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1129151161.183821.264480@g14g2000cwa.googlegroups.com>,
"ChiChiRuiz@gmail.com" <ChiChiRuiz@gmail.com> wrote:

> I have an image of pixels (xsize by ysize), each pixel is associated
> with a value. Say I'd like to know which pixels have value over 20. I
> need to book-keep the values as well as the location of the pixel (i.e.
> x, y values). I started with
>
> indices = where (image GT 20)
>
> now I have a list of indices, what do i do next? How do I go backwards
> to retrieve the values and the locations of the pixels that pass the
> test?
>
> thanks for your help.

values = image[indices]
locations = ARRAY_INDICES[image, indices]


But never do a WHERE without a count and subsequent IF

indices = WHERE(image GT 20, count)
IF (count GT 0) THEN ...


Cheers, Ken Bowman
Re: Quick question regarding "where" function [message #45826 is a reply to message #45825] Wed, 12 October 2005 14:40 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
ChiChiRuiz@gmail.com wrote:
> I have an image of pixels (xsize by ysize), each pixel is associated
> with a value. Say I'd like to know which pixels have value over 20. I
> need to book-keep the values as well as the location of the pixel (i.e.
> x, y values). I started with
>
> indices = where (image GT 20)
>
> now I have a list of indices, what do i do next? How do I go backwards
> to retrieve the values and the locations of the pixels that pass the
> test?

The locations of the pixels are the numbers in your indexes variable.
Remember that the where function (and others) index into your array as
if it were one-dimensional rather than two-dimensional, so will only see
these 1-d indexes rather than pairs of x,y indexes.

The values greater than 20 can be returned by indexing into your
original array with the array of indexes you just got from the where
function: values = image[indexes]

-Mike
Re: Quick question regarding "where" function [message #45923 is a reply to message #45825] Wed, 19 October 2005 15:09 Go to previous message
ChiChiRuiz@gmail.com is currently offline  ChiChiRuiz@gmail.com
Messages: 32
Registered: October 2005
Member
Thank you very much!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: newbie: sub-array extraction
Next Topic: Re: lighting /ALIASed models

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

Current Time: Wed Oct 08 15:11:03 PDT 2025

Total time taken to generate the page: 0.00828 seconds