2D and 3D filled objects. [message #33373] |
Thu, 26 December 2002 12:34  |
biomedthesis2002
Messages: 12 Registered: November 2002
|
Junior Member |
|
|
HI..
I'm trying to draw a circle and fill the circle with value 255. I
want to extend this to 3D to draw a sphere and fill the sphere with
value 255. Can anybody tell me how to obtain this.
Thanks.
|
|
|
Re: 2D and 3D filled objects. [message #33466 is a reply to message #33373] |
Fri, 27 December 2002 09:16  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning (david@dfanning.com) writes:
> Well, then, how about this:
>
> sphere = FltArr(20, 20, 20)
> FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
> sphere(x, y, z) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
> indices = Where(sphere GT 0)
> sphere(indices) = 255
Whoops! I guess I should have tested that code. I was
distracted by the plumber telling me know what the problem
is in the bathroom. Let's just say the era of free advice
may be a thing of the past. :-(
Try this:
sphere = FltArr(40, 40, 40)
FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
sphere(x+10, y+10, z+10) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
indices = Where(sphere Lt 9.5 AND sphere NE 0)
sphere(indices) = 255
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: 2D and 3D filled objects. [message #33467 is a reply to message #33373] |
Fri, 27 December 2002 09:03  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
New2IDL (biomedthesis2002@yahoo.com) writes:
> I already tried to generate the sphere the same way but the problem is
> it has various densities. I want a sphere with one density and that
> density is White.
>
> I've written my own code for 3D thinning. I'm not sure if the
> algorithm is right. I know what to expect when i thin a binary sphere.
> That's the reason for this question. To cross check that in 2D, i need
> a binary circle that is completely filled with each pixel value as
> 255.
Well, then, how about this:
sphere = FltArr(20, 20, 20)
FOR x=0,19 DO FOR y=0,19 DO FOR z=0,19 DO $
sphere(x, y, z) = SQRT((x-9.5)^2 + (y-9.5)^2 + (z-9.5)^2)
indices = Where(sphere GT 0)
sphere(indices) = 255
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|