filled contours with POLYFILL [message #21487] |
Tue, 29 August 2000 00:00  |
egraves
Messages: 9 Registered: January 2000
|
Junior Member |
|
|
Hi all,
I am drawing closed contours over an image, and would like to fill the contours with
a pattern which allows viewing of the image beneath (like a checkerboard). I have an
array of vertices which i plot using PLOTS, then i tried passing the vertices to
POLYFILL to fill in the enclosed area. I tried using a pattern of
[ [255, 0 ]
[0, 255] ]
to generate a checkerboard, but despite my finger crossing the zeroes in the pattern
are drawn as black and not left undrawn. Is there any simple way to achieve the kind
of "holey" pattern i'm looking for with POLYFILL? Or do i need to do something fancy
with POLYFILLV?
Thanks in advance,
Ted Graves
Magnetic Resonance Science Center, UCSF
|
|
|
Re: filled contours with POLYFILL [message #21568 is a reply to message #21487] |
Wed, 30 August 2000 00:00  |
Alex Schuster
Messages: 124 Registered: February 1997
|
Senior Member |
|
|
Ted Graves wrote:
Ted, could you set your right margin to about 72 characters? This makes
the quoted text easier to read.
> I am drawing closed contours over an image, and would like to fill the contours with
> a pattern which allows viewing of the image beneath (like a checkerboard). I have an
> array of vertices which i plot using PLOTS, then i tried passing the vertices to
> POLYFILL to fill in the enclosed area. I tried using a pattern of
>
> [ [255, 0 ]
> [0, 255] ]
>
> to generate a checkerboard, but despite my finger crossing the zeroes in the pattern
> are drawn as black and not left undrawn. Is there any simple way to achieve the kind
> of "holey" pattern i'm looking for with POLYFILL? Or do i need to do something fancy
> with POLYFILLV?
POLYFILL has a TRANSPARENT keyword which is exactly what you are looking
for, alas, it only works for the Z buffer. You could display your image
there, too, then use polyfill, grab the output and display it in a
'real' window.
set_plot, 'Z' ; switch graphics device to Z buffer
; draw some images
ployfill, x, y, /device, pattern=pattern, transparent=1 ; fill the
contour
image = tvrd( 0, 0, xsize, ysize ) ; capture output
set_plot, 'X' ; back to X (or set_plot, 'Win' if using Windows
tv, image ; display the captured output
Not too elegant, I admit. Another way would be not using polyfill:
; Grab the image from the screen with tvrd()
image = tvrd( 0, 0, xsize, ysize )
; make a copy
image2 = image
; set every 2nd pixel to 255. xsize needs to be odd for this to work!
; be sure xsize or ysize are long integers!
image2[lindgen( xsize*ysize/2 ) * 2] = 255
; get the indices inside the polygon
index = polyfillv( x, y, xsize, ysize )
; change the original image
image[index] = image2[index]
; re-display the altered image
tv, image
I didn't test this, but I think it should work. Easier solutions may
exist.
Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
|
|
|