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

Home » Public Forums » archive » Routine to return indices for circle in R2
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Routine to return indices for circle in R2 [message #9931] Mon, 08 September 1997 00:00
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Has someone written, seen or heard of a routine that will return
the indices of a circle within an image of given dimensions,
given the radius and center coordinate of the circle? I vaguely
remember seeing this in a newsgroup post some time ago.

For an image of size NX x NY, with the circle at coordinate (Cx,Cy)
and radius R, I came up with:

indices = lindgen(long(NX)*NY)
yc = indices / NY
xc = indices - (yc * NY)
circle = where( sqrt( (xc - Cx)^2 + (yc-Cy)^2 ) le R )

Can anyone suggest a method that is (a) faster, (b) more clever,
(c) more elegant, or (d) uses less memory. I'd be willing to settle
for just one of the above!

Thanks!

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Previous Topic: backround settings with render function
Next Topic: IDL Image Processing Expert Needed

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

Current Time: Mon Oct 13 04:29:55 PDT 2025

Total time taken to generate the page: 1.51896 seconds