[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IDLanROI Confusion


Alright. I admit it. I don't get it. :-(

I want to use the IDLanROI object to calculate
the perimeter, centroid, and area of a region of interest.
But I'm not sure the values can be trusted. Here is an

; Create a square window:

   Window, XSize=400, YSize=400

; Draw a circle of radius 50 pixels in the center of the window:

   TVCircle, 50, 200, 200, Color=255, /Fill

; Take a snap shot of the window:

   snap = TVRD()

; Contour the circle:

   IsoContour, snap, C_Value=255, connectivity, vertices

; Create an IDLanROI object:

   o = Obj_New('IDLanROI', connectivity[0,*], connectivity[1,*])

; Calculate geometry:

   ok = o->ComputeGeometry(Perimeter=p, Centroid=c, Area=a)

; Calculate perimeter, area of circle:

   radius = 50.0
   pcircle = 2 * !Pi * radius
   acircle = !Pi * radius^2

; Print it out, with expected values:

   Print, 'Calculated Perimeter: ', p
   Print, 'Expected Perimeter:   ', pcircle
   Print, 'Discrepancy in Perimeter (percent): ', p / pcircle * 100., '%'
   Print, ""
   Print, 'Calculated Area: ', a
   Print, 'Expected Area:   ', acircle
   Print, 'Discrepancy in Area (percent): ', a / acircle * 100., '%'
   Print, ""
   Print, 'Calculated Centroid: ', c[0:1]
   Print, 'Expected Centroid: ', 200, 200

Here are the results. 15% error in the perimeter is pretty large!

Calculated Perimeter:        362.61017
Expected Perimeter:         314.159
Discrepancy in Perimeter (percent):        115.42240%

Calculated Area:        7691.5000
Expected Area:         7853.98
Discrepancy in Area (percent):        97.931216%

Calculated Centroid:        199.50135       200.25225     
Expected Centroid:      200     200

Am I doing something wrong, or should I believe these numbers?
The same exercise with a square region produced accurate numbers.

My expected ROI's are not squares or circles, but they are
much closer to circles than squares.



David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155