I wrote the following little program to shift the lines of a single band image by correction factors organized in the file "correction_factors.txt".
;; Program to shift lines by specified values for image with one band
pro shifter_single_band
;; Open file with vector which contains the values each line has to be shifted by. The values
;; digitizing
openr, 1, 'C:\idl pro\test\RSI\correction_factors.txt'
a = intarr(1,45)
readf,1,a
;; Read in image
image_file = 'C:\idl pro\test\RSI\1_band_sub'
;; plug in image size
x_image = 63
y_image = 45
imagesize = [x_image, y_image]
image = read_binary (image_file, data_dims = imagesize, data_type = 12)
;; create empty array with populated with 0's
new_image = make_array(200, 200, value = 0)
;; Shift each row by value specified in the vector "correction_factors.txt"
for j = 0, 44 do begin
b = (50 + a[j])
for i = 0, 62 do begin
new_image[b,j] = image[i, j]
b = b+1
endfor
endfor
;; Write new image to spcified file
openw, 2, 'C:\idl pro\test\RSI\1_band_output'
writeu, 2, new_image
end
The resulting output image shows what I am expecting to see. Based on this result I was pretty sure that it would pretty easy to do the same thing for a multi band image. I just added another loop to take the third dimension into account and thought it would work the same way. However, I am getting not what I am expecting to see. The program I wrote for the multi band imagery reads as follows:
;; Program to shift lines by specified values for image with 240 bands
pro shifter_240
;; Open file with vector which contains the values each line has to be shifted by. The values
;; digitizing
openr, 1, 'C:\idl pro\test\RSI\correction_factors.txt'
a = intarr(1,45)
readf,1,a
;; Read in image
image_file = 'C:\idl pro\test\RSI\hyper_sub'
;; plug in image size
x_image = 63
y_image = 45
z_image = 240
imagesize = [x_image, y_image, z_image]
image = read_binary (image_file, data_dims = imagesize, data_type = 12)
;; create empty array with populated with 0's
new_image = make_array(200, 200,240, value = 0)
;; Shift each row by value specified in the vector "correction_factors.txt"
for Z = 0, 239 do begin
for j = 0, 44 do begin
b = (50 + a[j])
for i = 0, 62 do begin
new_image[b,j,z] = image[i,j,z]
b = b+1
endfor
endfor
endfor
;; Write new image to spcified file
openw, 2, 'C:\idl pro\test\RSI\output_240_band'
writeu, 2, new_image
end
It would be great if somebody could tell me what the problem is - I really appreciate your time and help with this
Cheers,
Jan
|