Dear community,
I have following problem. I want to stack two (or more) masks (each with three pixel values: 0,11 and 14) with the help of ENVI+IDL. My testcode works at now with only 2 masks whose pixel-sizes and scene-sizes are different (for that reason the /EXCLUSIVE-command). The code works right until the last few lines. I want to get an three-dimensional array (img_stacked) with the two band-layers each with the same x and y dimension (the one from the bigger mask).
I'm an IDL-beginner and would be glad about your help.
Thanks
My code:
pro layer_stack, out_name
mask_2000 = envi_pickfile(title='Pick a TIFF file from year 2000', $
filter='*.tif')
if (mask_2000 eq '') then return
print, 'The selected filename is: ', mask_2000
mask_1990 = envi_pickfile(title='Pick a TIFF file from year 1990', $
filter='*.tif')
if (mask_1990 eq '') then return
print, 'The selected filename is: ', mask_1990
envi_open_file, mask_2000, r_fid = t_fid
if (t_fid eq -1) then begin
envi_batch_exit
return
endif
envi_open_file, mask_1990, r_fid = d_fid
if (d_fid eq -1) then begin
envi_batch_exit
return
endif
ENVI_FILE_QUERY, t_fid, $
ns=t_ns, nl=t_nl, nb=t_nb ; ns = Number of samples; nl = Number of lines, nb = Number of bands
ENVI_FILE_QUERY, d_fid, $
ns=d_ns, nl=d_nl, nb=d_nb
;
nb = t_nb + d_nb ; Sum of bands
fid = lonarr(nb)
pos = lonarr(nb)
dims = lonarr(5, nb)
;
for i = 0L, t_nb-1 do begin
fid[i] = t_fid
pos[i] = i
dims[0,i] = [-1,0,d_ns-1,0,d_nl-1]
endfor
;
for i = t_nb, nb-1 do begin
fid[i] = d_fid
pos[i] = i-t_nb
dims[0,i] = [-1,0,d_ns-1,0,d_nl-1]
endfor
;
out_proj = envi_get_projection(fid = t_fid, $
pixel_size = out_ps)
out_name = 'C:\folder\subfolder\...'
out_dt = 1
;
envi_doit, 'envi_layer_stacking_doit', $
fid = fid, pos = pos, dims = dims, $
/EXCLUSIVE, out_dt = out_dt, out_name = out_name, $
interp = 0, out_ps = out_ps, $
out_proj = out_proj, r_fid = r_fid
;
; ENVI_FILE_QUERY, r_fid, $
; dims=dims
img_stacked = ENVI_GET_DATA(fid = r_fid, dims = dims, pos = 0)
print, ''
end
|