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

Home » Public Forums » archive » IDLanROI Confusion
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
IDLanROI Confusion [message #24572] Wed, 04 April 2001 13:33
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Folks,

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
example.

************************************************************ ******
; 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.

Cheers,

David

--
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL to display USGS DOQ data.
Next Topic: Congrid but with shift of origin

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

Current Time: Wed Oct 08 13:47:55 PDT 2025

Total time taken to generate the page: 0.00607 seconds