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

Home » Public Forums » archive » Getting x and y positions from a mask
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
Getting x and y positions from a mask [message #77087] Fri, 29 July 2011 03:32
S. Murray is currently offline  S. Murray
Messages: 6
Registered: July 2010
Junior Member
I am trying to obtain x and y coordinates of all the pixels within a
very specific mask that I have created (thresholded contour in an
image, but just one of the thresholded contours of the image, not all
of them). Firstly, I used the contour procedure (path_xy, path_info,
getting data coordinates...) and then used objects to get my mask from
this- something along the lines of here:

http://idlastro.gsfc.nasa.gov/idl_html_help/Programmatically _Defining_ROIs.html

I used 'mask_rule=2 'so I that I have a mask of all pixels falling on
or within a the regions boundary. I now have this mask array, which is
just a 2d byte array:

IDL> help,mask
MASK BYTE = Array[151, 151]

I want to find out what the x and y coordinates are of all pixels that
are '1's' in 'mask'. I wish to run a procedure on all pixels within
this contoured region but I cant figure out how to make an array of
the x and y coordinates. I know I could get the contour path pixels by
typing something like this from just the contour procedure:

line = [ LINDGEN( path_info[i].n ), 0 ]
path_coords=path_xy[*, path_info[i].offset + line]

But this does not include ALL pixels within the contoured region. I've
only ever come across the cursor procedure before which saves x and y
positions after clicking on the x display, however this won't exactly
be very useful for all 568 pixels in the mask!

Does anyone have any ideas? I don't know if its just because I'm not
proficient enough in IDL yet or if its because I've been working on
this for too long, but I have a feeling its a simple enough procedure
if I figure out what to use!
Re: Getting x and y positions from a mask [message #77089 is a reply to message #77087] Thu, 28 July 2011 14:06 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
S. Murray writes:

> I am trying to obtain pixels coordinates of all the pixels within a
> very specific mask that I have created (thresholded contour in an
> image, but just one of the thresholded contours of the image, not all
> of them). Firstly, I used the contour procedure (path_xy, path_info,
> getting data coordinates...) and then used objects to get my mask from
> this- something along the lines of here:
>
> http://idlastro.gsfc.nasa.gov/idl_html_help/Programmatically _Defining_ROIs.html
>
> I used 'mask_rule=2 'so I that I have a mask of all pixels falling on
> or within a the regions boundary. I now have this mask array, which is
> just a 2d byte array:
>
> IDL> help,mask
> MASK BYTE = Array[151, 151]
>
> I want to find out what the x and y coordinates are of all pixels that
> are '1's' in 'mask'. I wish to run a procedure on all pixels within
> this contoured region but I cant figure out how to make an array of
> the x and y coordinates. I know I could get the contour path pixels by
> typing something like this from just the contour procedure:
>
> line = [ LINDGEN( path_info[i].n ), 0 ]
> path_coords=path_xy[*, path_info[i].offset + line]
>
> But this does not include ALL pixels within the contoured region. I've
> only ever come across the cursor procedure before which saves x and y
> positions after clicking on the x display, however this won't exactly
> be very useful for all 568 pixels in the mask!
>
> Does anyone have any ideas? I don't know if its just because I'm not
> proficient enough in IDL yet or if its because I've been working on
> this for too long, but I have a feeling its a simple enough procedure
> if I figure out what to use!

I'd do something like this:

indices = Where(mask EQ 1)
xy = Array_Indices(mask, indices)
x = Reform(xy[0,*])
y = Reform(xy[1,*])

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 on Mac OS X 10.7 (Lion)
Next Topic: Re: Getting x and y positions from a mask

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

Current Time: Wed Oct 08 13:49:31 PDT 2025

Total time taken to generate the page: 0.00594 seconds