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

Home » Public Forums » archive » Re: Computing the average of a non-rectangular region in IDL
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: Computing the average of a non-rectangular region in IDL [message #1011] Fri, 28 May 1993 16:03
deutsch is currently offline  deutsch
Messages: 19
Registered: February 1992
Junior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Computing the average of a non-rectangular region in IDL
Next Topic: idl: how to extract pictures from slicer?

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

Current Time: Sat Oct 11 01:12:14 PDT 2025

Total time taken to generate the page: 0.47935 seconds