Compute Euclidean distances [message #54151] |
Fri, 25 May 2007 00:46  |
lbusett@yahoo.it
Messages: 30 Registered: February 2006
|
Member |
|
|
Hi all,
I have the following problem: given an image of about 700000
pixels, i need to calculate the distance between each pixel and about
150 points of known coordinates. Actually, I'm actually using a simple
for loop like that:
; map_x = array of east coordinates of each pixel (n =
700000)
; map_y = array of north coordinate of each pixel (n
= 700000)
; east = array of east coordinates of the each point
(n= 150)
; north = array of north coordinates of the each
point (n= 150)
; dist_pt ="results" array (n = 700000*150)
;
for point= 0, n_points-1 do begin
dist_x = (map_x - East [point])^2
dist_y =(map_y - North [point])^2
dist_pt [*,point] = sqrt ( dist_x + dist_y)
endfor
but the processing is quite slow (more than one minute on my PC), so
i'd like to ask you if there is a way to increase the speed of the
process.
Thanks in advance for the help,
Lorenzo Busetto
|
|
|
|