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

Home » Public Forums » archive » Re: Maximum radius of SEARCH2D/SEARCH3D
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Maximum radius of SEARCH2D/SEARCH3D [message #34726] Mon, 14 April 2003 19:03 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Alexander Gro� (AlexanderGross_NOSPAM@gmx.de) writes:

> Unfortunately there's one stupid question left:
> How to determine cols, rows and frames for 3D space? :)

I thought we answered that question for you last week. :-)

Here is an article, along with a pointer to the L_GETDIM
code offered by Mark Schellens:

http://www.dfanning.com/tips/where_to_2d.html

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: Maximum radius of SEARCH2D/SEARCH3D [message #34728 is a reply to message #34726] Mon, 14 April 2003 14:28 Go to previous messageGo to next message
Alexander Gro� is currently offline  Alexander Gro�
Messages: 7
Registered: April 2003
Junior Member
|David Fanning" <david@dfanning.com> schrieb im Newsbeitrag
news:MPG.1904ce8036cec863989b50@news.frii.com...
| indices = Search2d(array, x, y)
| s = Size(array, /Dimensions)
| cols = indices MOD s[0]
| rows = indices / s[0]
| radius = Sqrt( (cols - x)^2 + (rows - y)^2)
| goodPixels = Where(radius LT myCircleRadius)
| cols = cols[goodPixels]
| rows = rows[goodPixels]

That's looking much better. Slowly I get behind the tricks of IDL. In the
past I was coding only C, so I am used to write for loops when I wanted to
process all elements of an array. I've learned very much, thanks again.

Unfortunately there's one stupid question left:
How to determine cols, rows and frames for 3D space? :)

| > Thank you very much for sharing your deep insight of IDL. :-)
| I think you have me confused with JD. :-)
Mhh, maybe this was caused due to my social activities this weekend. J/K :)

Alex

_______________________________________

Alexander Gro�
Dipl.-Ing. (BA) f�r Informationstechnik
AlexanderGross@gmx.de
http://www.it99.org/axl
+49 (0) 1 75/ 410 72 68
ICQ# 36765668
_______________________________________
Re: Maximum radius of SEARCH2D/SEARCH3D [message #34729 is a reply to message #34728] Mon, 14 April 2003 13:56 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Alexander Gro� (AlexanderGross_NOSPAM@gmx.de) writes:

> thank you very much. It's working good. For the distance caluculation I used
> a for loop. I did not implement the square root function for distance
> calculation since this costs CPU time. I raised the allowed maximum radius
> to the power of two and compare it to the computed distance each time.
>
> Only for my understanding: Is is possible to do this without the "evil" for
> loop? Is there another way to tell IDL that the operation has to be done for
> each element of the subscripts array?

For the 2D case, I was envisioning something like this:

indices = Search2d(array, x, y)
s = Size(array, /Dimensions)
cols = indices MOD s[0]
rows = indices / s[0]
radius = Sqrt( (cols - x)^2 + (rows - y)^2)
goodPixels = Where(radius LT myCircleRadius)
cols = cols[goodPixels]
rows = rows[goodPixels]

> Thank you very much for sharing your deep insight of IDL. :-)

I think you have me confused with JD. :-)

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: Maximum radius of SEARCH2D/SEARCH3D [message #34730 is a reply to message #34729] Mon, 14 April 2003 13:41 Go to previous messageGo to next message
Alexander Gro� is currently offline  Alexander Gro�
Messages: 7
Registered: April 2003
Junior Member
Hi David,

thank you very much. It's working good. For the distance caluculation I used
a for loop. I did not implement the square root function for distance
calculation since this costs CPU time. I raised the allowed maximum radius
to the power of two and compare it to the computed distance each time.

Only for my understanding: Is is possible to do this without the "evil" for
loop? Is there another way to tell IDL that the operation has to be done for
each element of the subscripts array?

Thank you very much for sharing your deep insight of IDL. :-)

Alex

_______________________________________

Alexander Gro�
Dipl.-Ing. (BA) f�r Informationstechnik
AlexanderGross@gmx.de
http://www.it99.org/axl
+49 (0) 1 75/ 410 72 68
ICQ# 36765668
_______________________________________
Re: Maximum radius of SEARCH2D/SEARCH3D [message #34735 is a reply to message #34730] Mon, 14 April 2003 06:16 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning (david@dfanning.com) writes:

> All of this can be easily vectorized, so it soul be extremely fast.

Whoops! Little Freudian slip there, no doubt caused by
social activities this weekend. :-(

Should read, "so it *should* be extremely fast".

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: Maximum radius of SEARCH2D/SEARCH3D [message #34736 is a reply to message #34735] Mon, 14 April 2003 06:13 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Alexander Gro� (AlexanderGross_NOSPAM@gmx.de) writes:

> I have a question about the very useful functions SEARCH2D and SEARCH3D. Is
> it possible to limit the search for similar cells to a radius or sphere
> surrounding the pixel referred by the xpos/ypos/zpos-parameters of these
> functions? If not, is it possible to implement an algorithm (if no built-in
> function is available) that takes the indices returned by these functions an
> cut every index that lies outside a specified radius/sphere? I would
> appreciate if you could give me a hint how this algorithm may look like.

This seems fairly straightforward to me.

1. Convert indices to 2D or 3D subscripts (article here last week).
2. Calculate distance (radius) from each index to the seed point.
3. Discard if distance is greater than radius of circle or sphere.

All of this can be easily vectorized, so it soul be extremely fast.

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: Maximum radius of SEARCH2D/SEARCH3D [message #34811 is a reply to message #34726] Wed, 16 April 2003 14:08 Go to previous message
Alexander Gro� is currently offline  Alexander Gro�
Messages: 7
Registered: April 2003
Junior Member
Sorry David. I was just to silly to link your answer from last week to this
case. I thought there might be something else to do to get the coordinates
of the array values. Why, I don't know for sure. Anyway, thanks for your
support. Also in the terrible cases like me :)

Best regards,

Alex
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Image Plots
Next Topic: Re: Image Plots

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

Current Time: Wed Oct 08 18:13:42 PDT 2025

Total time taken to generate the page: 0.00559 seconds