In article <1u5ruh$k4o@skates.gsfc.nasa.gov>, gumley@ltpiris2.gsfc.nasa.gov (Liam Gumley) writes:
> Hey folks.
> I need to select a polygon of pixels in an image with the mouse, and then
> compute the mean value of the pixels within the polygon.
> Does anybody have an IDL procedure that will do this, or know here I can
> get one?
>
> Cheers,
> Liam.
>
The DEFROI() function does what you want. I have that function implemented
as part of a image "roaming" program in IDL. It requires the ASTRONOMY
library at present. If you have this and want to try it, drop me a note.
In any event, here is the bit of code that I'm using with DEFROI():
print,'Define new HII Region'
win_set,FrameWIN
reslt=DefROI(512,512,xverts,yverts,/noregion)
xverts=xverts*1./zoom+xmin-0.5
yverts=yverts*1./zoom+ymin-0.5
if (n_elements(ROInum) eq 0) then ROInum=0
openw,funit,'ROI'+strn(ROInum,length=3,padchar='0')+'.dat',/ GET_LUN
printf,funit,'; Region of Interest (ROI) Dump File'
printf,funit,'; Polygon Information:
tmp=polyfillv(xverts+1.0,yverts+1.0,NAXIS1,NAXIS2)
printf,funit,'NVERTS = ',strn(n_elements(xverts))
printf,funit,'NPIXELS = ',strn(n_elements(tmp))
printf,funit,'COUNTS = ',strn(total(image(tmp)))
printf,funit,'; List of Vertices follows:'
for qi=0,n_elements(xverts)-1 do printf,funit,xverts(qi),yverts(qi)
close,funit & free_lun,funit & ROInum=ROInum+1
wait,1
where ZOOM is the zoom factor of the displayed image and XMIN and YMIN
correspond to the lower left pixel of the overall image displayed in your
window.
hope this helps...
cheers,
Eric
Eric Deutsch
University of Washington
Department of Astronomy FM-20
Seattle, WA 98195
deutsch@astro.washington.edu or UWSPAN::JANUS::DEUTSCH
|