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

Home » Public Forums » archive » Help requested in eradicating FOR loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Help requested in eradicating FOR loops [message #57710 is a reply to message #57539] Tue, 18 December 2007 05:23 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Dec 18, 11:00 am, dplat...@gmail.com wrote:
>> Off the top of my head:
>> 1-reform the points to match the size of the image: x1 =
>> reform(x1,image_height,image_width)
>> 2-make in "index" array: idx = findgen(image_height,image_width)
>> 3-make x-index and y-index arrays: x = idx mod image_height & y = idx/
>> image_height (or maybe those should be image_width?)
>> 4-do the calculation: distance = ( (y1-y2)*x + (x2-x1)*y + (x1*y2-
>> x2*y1) ) / SQRT( (x2-x1)^2 + (y2-y1)^2 )
>> 5-put together the results matrix: results =
>> [[reform(image,image_height*image_width)],[distance]] (I'd have to
>> check the brackets, I always do)
>
> Thanks for the reply - as I understand it I need to make an array to
> hold x pixel positions and one to hold y pixel positions. For a 4 x 6
> array they would look like this:
>
> x locations: [0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3]
> y locations: [0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5]
>
> I can make the x array by doing this:
>
> test_image = findgen(4, 6) ; a dummy test "image"
> temp = findgen(4 * 6)
> x_locations = temp mod 4
>
> but I am having problems creating the y locations array. Some help
> would be appreciated.
>
> Thanks, David

y_locations = fix(temp) / 4
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: iTools problem
Next Topic: Starting a for loop within an if loop

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

Current Time: Sun Oct 12 06:26:47 PDT 2025

Total time taken to generate the page: 1.43664 seconds