Re: Intersecting geometric shapes [message #25527] |
Thu, 28 June 2001 23:14  |
m.hadfield
Messages: 36 Registered: April 2001
|
Member |
|
|
From: "Rick Towler" <rtowler@u.washington.edu>
Newsgroups: comp.lang.idl-pvwave
Sent: Friday, June 29, 2001 6:00 PM
Subject: Re: Intersecting geometric shapes
> I'm sure there is a more elegant way of doing this but since
> your post has sat here all day without a response...
I was reticent for exactly the same reason, but since you've poked your head
above the parapet...
> Fire up your favorite drawing program and create a new
> image, say 200x200. Draw your circle white on black. Now
> create another 200x200 image this time drawing your rectangle.
> Save as an indexed color image (.gif (pre IDL 5.4)
> or .png should work)
>
> load these images into IDL, add the arrays, and do a where on
> the new array for values that are double your white color palette
> index value. The number of elements in the result of your where will
> give you the pixel area of your intersection. Then all you have to do
> is convert pixel area back to your measure of area.
I'd like to point out that you can do essentially the same thing without
actually drawing anything using the POLYFILLV function.
Of course drawing the shapes out with POLYFILL to check what you're doing
isn't a bad idea either...
---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
|
|
|
Re: Intersecting geometric shapes [message #25528 is a reply to message #25527] |
Thu, 28 June 2001 23:00   |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
I'm sure there is a more elegant way of doing this but since your post has
sat here all day without a response...
Fire up your favorite drawing program and create a new image, say 200x200.
Draw your circle white on black. Now create another 200x200 image this time
drawing your rectangle. Save as an indexed color image (.gif (pre IDL 5.4)
or .png should work)
load these images into IDL, add the arrays, and do a where on the new array
for values that are double your white color palette index value. The number
of elements in the result of your where will give you the pixel area of your
intersection. Then all you have to do is convert pixel area back to your
measure of area.
There are a lot of details. You have to scale your original shapes
correctly, converting from your measure to pixel area. Then you need to
arrange your shapes in your image correctly. Also, you have to figure out
how your image program indexes the color palette (this is easy, just print
the image data out. You only have two colors and you'll see two values.
They may be 0 and 1. They may be 0 and 255. It depends on the program you
use to write the images).
This is a pretty simple approach. You could spice it up so it is more
flexible.
-Rick
"Joe Means" <means@fsl.orst.edu> wrote in message
news:3B3B8421.3080005@fsl.orst.edu...
> Hello IDL group,
> I need to calculate the area of intersecting geometric shapes. Right
> now a circle and rectangle. Does nayone know of code to do this?
>
> --
> Joseph E. Means
> Assistant Professor, joe.means@orst.edu
> Department of Forest Science
> Oregon State University
> Corvallis, OR 97331-5752
> 541-750-7351
>
|
|
|
Re: Intersecting geometric shapes [message #25616 is a reply to message #25527] |
Fri, 29 June 2001 09:25  |
Joe Means
Messages: 44 Registered: November 1996
|
Member |
|
|
Thanks to Rick and Mark for your thoughtful responses.
Joe Means
Mark Hadfield wrote:
> From: "Rick Towler" <rtowler@u.washington.edu>
> Newsgroups: comp.lang.idl-pvwave
> Sent: Friday, June 29, 2001 6:00 PM
> Subject: Re: Intersecting geometric shapes
>
>
>> I'm sure there is a more elegant way of doing this but since
>> your post has sat here all day without a response...
>
>
> I was reticent for exactly the same reason, but since you've poked your head
> above the parapet...
>
>> Fire up your favorite drawing program and create a new
>> image, say 200x200. Draw your circle white on black. Now
>> create another 200x200 image this time drawing your rectangle.
>> Save as an indexed color image (.gif (pre IDL 5.4)
>> or .png should work)
>>
>> load these images into IDL, add the arrays, and do a where on
>> the new array for values that are double your white color palette
>> index value. The number of elements in the result of your where will
>> give you the pixel area of your intersection. Then all you have to do
>> is convert pixel area back to your measure of area.
>
>
> I'd like to point out that you can do essentially the same thing without
> actually drawing anything using the POLYFILLV function.
>
> Of course drawing the shapes out with POLYFILL to check what you're doing
> isn't a bad idea either...
>
> ---
> Mark Hadfield
> m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
> National Institute for Water and Atmospheric Research
>
>
>
>
--
Joseph E. Means
Assistant Professor, joe.means@orst.edu
Department of Forest Science
Oregon State University
Corvallis, OR 97331-5752
541-750-7351
|
|
|