Re: adding subset image into larger one [message #70168] |
Tue, 23 March 2010 19:02  |
Suguru Amakubo
Messages: 24 Registered: March 2010
|
Junior Member |
|
|
Ah I see! That explains it so essentially its:
new_image[tr_point[0,a]:tr_point[0,a]+L-1,tr_point[1,a]:tr_p oint[1,a]
+L-1] = new_image[tr_point[0,a]:tr_point[0,a]
+L-1,tr_point[1,a]:tr_point[1,a]+L-1] + temp_image
thus just adding to the part of the new_image array. Sorry I was a bit
confused earlier.
One question though is that when I run this I was given a run time
error saying that I am out of range on the first cycle of the loop
(when I checked the coordinates are sane and is not out of range):
(Some changes were added to avoid out of range errors, unrelated to
above):
nn=n_elements(mc_point(0,*))
;for loop that runs through the array and places blocks on top of the
image
for kk=0L,nn-1 do begin
x0 = mc_point(0,kk)
y0 = mc_point(1,kk)
if (x0 ge size_of_image - L) or (y0 ge size_of_image - L) then begin
if x0 ge size_of_image -L && y0 ge size_of_image -L then begin
temp_image = new_image2[size_of_image -L: size_of_image-1,
size_of_image -L:size_of_image-1]
endif else if x0 ge size_of_image -L && y0 le size_of_image - L &&
y0 ge 0 then begin
temp_image = new_image2[size_of_image -L:size_of_image-1, y0:y0+L-1]
endif else if x0 le size_of_image -L and y0 ge size_of_image -L and
x0 ge 0 then begin
temp_image = new_image2[x0:x0+L-1 , size_of_image -
L:size_of_image-1]
endif
endif else begin
;extracting the block from the original image
temp_image = new_image2[mc_point[0,kk]:mc_point[0,kk]
+L-1,mc_point[1,kk]:mc_point[1,kk]+L-1]
;adding the subset to a 400x400 image
;The error occures here
new_image[tr_point[0,kk]:tr_point[0,kk]
+L-1,tr_point[1,kk]:tr_point[1,kk]+L-1] += temp_image
;adding an 30x30 array of 1s to a blank 400x400 image population
population[tr_point[0,kk]:tr_point[0,kk]
+L,tr_point[1,kk]:tr_point[1,kk]+L] += coverage_image
endelse
endfor
sorry about the text wrapping and thank you all for the help :)
|
|
|