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

Home » Public Forums » archive » Polygon filling oddities
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Polygon filling oddities [message #26946] Wed, 03 October 2001 17:47 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Hello all

I have been experimenting with different methods of generating images
representing filled polygons. (My motivation comes from attempts at drawing
filled coastlines on various devices.) I have found some oddities when using
the POLYFILLV routine and the IDLanROI object. Before I take this issue to
RSI tech support I thought I'd show it to the group and ask whether what I
am doing makes sense.

The procedure below (and attached) illustrates the problem. It displays a
500 x 500 image with a centred circle of radius 300 using several methods,
controlled by the option argument:

0 Call POLYFILL directly to window
1 Use POLYFILLV to create an image then display image
2 Use POLYFILL to create the image in a Z buffer then display image
3 Create an IDLanROI object and use its ComputeMask method to create an
image, then display image.

These all seem to work and to give identical results, except perhaps for
some minor differences around the edge of the polygon.

The routine also accepts a SHIFT keyword that lets the caller shift the
circle around on the image plane. With options 0 and 2 this works exactly as
expected: as SHIFT is increased the circle moves to the edge of the window
and eventually disappears. But with options 1 and 3 the results are
unexpected: as SHIFT is made more negative the circle vanishes abruptly when
it passes a threshold.

For example "mgh_test_polyfill, 1, -143" (using POLYFILLV) produces a circle
with its edge not quite touching the lower left corner of the image and
"mgh_test_polyfill, 1, -144" produces a blank image. Similarly
"mgh_test_polyfill, 3, -101" (using IDLanROI::ComputeMask) produces a circle
with its edges touching the bottom and left sides of the image and
"mgh_test_polyfill, 3, -101" produces a blank image.

I guess POLYFILLV and IDLanROI are intended for dealing with regions of
interest on images and it is anticipated that the vertices of the ROI will
be in the positive quarter-plane. But I don't see any reason why they
shouldn't be able to work with negative vertex coordinates.

So is what I've found a bug or a feature? Can others reproduce my results?
(I've been using IDL 5.4.)

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research

------ mgh_test_polyfill -----------

; Testing various methods of polygon filling

pro mgh_test_polyfill, option, SHIFT=shift

compile_opt IDL2

if n_elements(option) eq 0 then option = 0

if n_elements(shift) eq 0 then shift = 0
if n_elements(shift) eq 1 then shift = [shift,shift]

; Create a window dimensioned [500,500]

window, XSIZE=500, YSIZE=500

; Set up coordinates defining a circle, radius 150, centred at 250

n_vert = 50

angle = 2.*!pi*findgen(n_vert+1)/float(n_vert)

x = 250 + 150*sin(angle)
y = 250 + 150*cos(angle)

; Shift the circle

x = x + shift[0]
y = y + shift[1]

; Generate & display and image using different methods depending on
option argument

case option of

0: polyfill, x, y, /DEVICE

1: begin
image = replicate(0B, 500, 500)
p = polyfillv(x, y, 500, 500)
if min(p) gt 0 then image[p] = 255B
tv, image
end

2: begin
dname = !d.name
set_plot, 'Z'
device, SET_RESOLUTION=[500,500]
erase
polyfill, x, y, /DEVICE
image = tvrd()
set_plot, dname
tv, image
end

3: begin
roi = obj_new('IDLanROI', x, y)
image = roi->ComputeMask(DIMENSIONS=[500,500])
obj_destroy, roi
tv, image
end

endcase

end


--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
[Message index]
 
Read Message
Read Message
Previous Topic: Can you drag and drop a Windows file into a Draw Widget?
Next Topic: the precision of PRINT and HELP statements

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

Current Time: Sun Oct 12 13:17:07 PDT 2025

Total time taken to generate the page: 0.21606 seconds