user-selected ROIs [message #72029] |
Wed, 04 August 2010 09:47  |
geogal34
Messages: 6 Registered: August 2010
|
Junior Member |
|
|
I have generated an output contour map of masses projected on a map
and would like to be able to allow the user to select a specific
region of interest and calculate the mass for that area. Basically I
just need to add up the value of all the pixels contained within the
boundary.
I’ve tried using XROI, but haven’t had any luck because the actual
values (masses) of the pixels aren’t what is shown in the histogram
when the image is passed. I’ve tried several different ways of passing
the data, but to no avail.
So I have chosen to draw a polygon point by point using CURSOR, then
plan to use a WHERE statement to figure out all the pixels within the
ROI. I use a similar procedure to determine a larger subset of the
satellite data, but that only has two points. The problem I’m
encountering is that, while I can print the latitudes and longitudes
as the mouse is clicked, I can’t seem to save them to an array because
the x, y positions are constantly being overwritten. What I'm trying
to do it save the initial array and then add new ones as they are
created. This code adds new lines to the array, but it just fills it
with the same points (lat/lon).
;Drawing polygon point by point
clicks=0
CURSOR, x, y, /DOWN, /DATA
PLOTS, x, y, PSYM=1, /DATA
WHILE (!MOUSE.button NE 4) DO BEGIN
CURSOR, x1, y1, /DOWN, /DATA
PLOTS, [x, x1], [y, y1], /DATA
; x=x1 & y=y1
IF (!MOUSE.button EQ 1 OR 4) THEN BEGIN
clicks=clicks+1
print, 'Clicks=', clicks, ' ', 'X=',x, ' ', 'Y=', y
cloud_array=fltarr(2, clicks)
FOR i=0, clicks-1 DO BEGIN
cloud_array(0,i)=[x]
cloud_array(1,i)=[y]
ENDFOR
print, 'i=', i
print, cloud_array
ENDIF
x=x1 & y=y1
ENDWHILE
There’s probably a simple solution, but I’ve been going in circles for
a while and now everything is a jumble in my head. Can anyone point in
the right direction? Or has anyone been able to do what I’m trying to
accomplish? I imagine there is probably a more elegant way and I'm not
even sure if this way makes sense!
Thanks!
Emily
|
|
|
Re: user-selected ROIs [message #72152 is a reply to message #72029] |
Thu, 05 August 2010 06:17  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
geogal34 writes:
> Thanks, David. I've managed to get the mask and indices from the
> PolyFillV procedure, now I just have to figure out how to work with
> them. I'm not really clear on how to use the REVERSE_INDICES yet, but
> I'm playing with it. I always find it hard to translate what I'm doing
> on the screen to my actual data (the retrieving part). It's just not
> always intuitive to me. Thanks again!
Yes, you just have to get over the idea that you are
looking at "your data". Unless you are looking at
pages and pages of numbers, that's rarely ever true.
At best, you are looking at a representation of your
data on a computer screen. That representation can
be manipulated in an infinite number of ways to give
us insight into what the data means. But that is not
the same as what the data is.
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.")
|
|
|