IDLanROI::ContainsPoints when TYPE = 0 (points) [message #52682] |
Wed, 14 February 2007 08:36 |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Hi All,
This is just a little FYI for anyone that uses IDLanROI::ContainsPoints.
I'm not sure if I am pleased or confused by what I would call a
documentation bug for IDLanROI::ContainsPoints. My impression from the
documentation for the method (see below) is that when the ROI is a set
of points OR an open path that any [X,Y,Z] points you want to test will
always come back exterior. I hate to admit that I really did read the
directions long ago and have, ever since, been jumping through hoops to
get something similar to ContainsPoints for ROI types 0 and 1. See the
last line of the documentation below.
;Syntax
;Result = Obj->[IDLanROI::]ContainsPoints( X [, Y [, Z]] )
;Return Value
;The return value is a vector of values, one per provided point,
indicating whether
;that point is contained. Valid values within this return vector include:
; 0 = Exterior. The point lies strictly out of bounds of the ROI
; 1 = Interior. The point lies strictly inside the bounds of the ROI
; 2 = On edge. The point lies on an edge of the ROI boundary
; 3 = On vertex. The point matches a vertex of the ROI
;A point is considered to be exterior if:
; The point falls within the boundary of an interior region (hole)
; The point does not lie in the plane of the region
; The region TYPE property is set to 0 (points) or 1 (path)
Alas, this last statement doesn't seem to be the case for version...
{ ppc darwin unix Mac OS X 6.3 Mar 23 2006 32 64}
It appears that IDL really works for at least ROI type = 0 (points). I
would guess that a convex hull is drawn around the points and that is
used for testing. So, I am pleased I can use IDLanROI::ContainsPoints
for type = 0, but chagrined that I never tried it after reading the
online help (until today when I forgot the manual says it doesn't do that!)
Thank goodness I forgot to take my memory medicine this morning!
x = [[0,0], [0,2], [1,3], [2,2], [2,0]]
o = obj_new('idlanroi', x, type = 0)
print, o->ContainsPoints(1,1)
; 1 ----> interior
print, o->ContainsPoints(0,0)
; 3 ----> on vertex
print, o->ContainsPoints(0,1)
; 2 -----> on edge
print, o->ContainsPoints(-1,-1)
; 0 ------> exterior
print, o->ContainsPoints(1,2.5)
; 1 ------>interior
print, o->ContainsPoints(0.2,2.5)
; 0 ------> exterior
o->GetProperty, type = t
print, t
; 0 ------> it really is a TYPE 0 ROI!
I haven't tried this for a path ROI (type = 1). I would prefer this to
be a documentation bug rather than a code bug.
Cheers,
Ben
|
|
|