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

Home » Public Forums » archive » Re: How to define resolution (not dimension!) for IDLanRoi->computeMask
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: How to define resolution (not dimension!) for IDLanRoi->computeMask [message #65054] Mon, 09 February 2009 06:37
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
justspam03@yahoo.de writes:

> I'm stuck with the following:
> I got a 2-dim image, say 256x256 pixels which spans (in real world
> coordinates) the region from [1,1] to [5,5].
> Plus I got ROIs defined on this image, say a rectangular ROI with x/y
> coords [2,2], [2,4], [3,4], [3,2].
>
> Now I'd like to have a mask for this ROI with the pixel dimensions of
> the image.
>
> roi = obj_new('IDLanRoi', .... real world ROI coordinates here )
> mask = roi->computeMask( dimensions=[256,256], location=[1.,1.], ...
> and now? )
>
> Is there a way to specify the 'real world' size of the mask pixels
> (i.e. 1 pixel = 1/64 cm)?

I don't think this is going to work the way you want
it to work using IDLanROI. I would create the mask like
this:

s = Size(image, /DIMENSIONS)
x = [2, 2, 3, 3, 2]
y = [2, 4, 4, 2, 2]
mask = BytArr(s[0], s[1])

To find the pixels in the mask, set up a data coordinate
system, and convert ROI coordinates to device coordinates.

Window, XSIZE=s[0], YSIZE=s[1], /PIXMAP
thisWindow = !D.Window
xrange = [1,5]
yrange = [1,5]
!X.S = FSC_Normalize(xrange)
!Y.S = FSC_Normalize(yrange)
!X.Window = [0,1]
!Y.Window = [0,1]
!X.CRange = xrange
!Y.CRange = yrange
xy = Convert_Coord(x, y, /DATA, /TO_DEVICE)
WDelete, thisWindow

Now fill the pixels inside your area with 1 (or 255, whatever
is appropriate for you).

indices = PolyFillV(xy[0,*], xy[1,*], s[0], s[1])
mask[indices] = 1B

You can find FSC_Normalize here:

http://www.dfanning.com/programs/fsc_normalize.pro

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: How to define resolution (not dimension!) for IDLanRoi->computeMask
Next Topic: Re: Has anyone worked with ARF files and brought them into IDL successfully?

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

Current Time: Wed Oct 08 19:46:02 PDT 2025

Total time taken to generate the page: 0.00460 seconds