Simple? problem [message #30081] |
Tue, 09 April 2002 08:49  |
Ivan Valtchanov
Messages: 8 Registered: April 2002
|
Junior Member |
|
|
Hi,
I have a small problem concerning a good programming techniques, so here it is:
----------------------
pro test,nx,ny,image
; Make some random X and Y arrays
x = randomu(s,1000)
y = randomu(s,1000)
; now give arbitrary weights for each point
w = randomu(s,1000)/100.0
; take the square
w2=2.0*w*w
; I want to construct a 2-D image with a specified dimension
image = fltarr(nx,ny)
; I want to sum up the contribution of each point as Gaussian
; with width=w to the image pixels
for i=0, nx-1 do begin
xgi = i/float(nx)
dx = x-xgi
for j=0, ny-1 do begin
ygi = j/float(ny)
dy = y-ygi
dr2 = dx*dx+dy*dy
arg = -dr2/w2 > (-20.0) ; to avoid overflows
image[i,j] = total(exp(arg))
endfor
endfor
return
end
---------------------------
This is obviously quite unoptimised - two cycles etc. Do you have any ideas, references or do you know if it is already solved in IDL?
I have looked for something similar in David Fanning pages and IDL astronomical libraries but I couldn't find something to adapt, maybe I have missed it?
Thanks.
Ivan V.
|
|
|