The first thing I'd suggest doing would be to clean up your code.
That's the easiest way to spot mistakes, and there are a few here you
should fix. First, you assign the filename for can_tmr.img to the
variable 'img_file', but then in the next line you try to open
'image_file' - see the difference? Also, i'm surprised this code is
even running b/c of this line:
roi_ids = envi_get_roi_ids(fid=r_fid)
The variable r_fid is undefined, as I see it. Once you get past these
things I think you'll be in a much better position to figure out for
yourself why your code isn't doing what you think it should. You
might, for example, examine the values that are stored in ns and nl.
Are they the same dimensions as your input image? If they are, then
that's the reason that your 'subset' image ends up with the same
dimensions as the input :)
Cheers,
Jeff
gis_learner wrote:
> Dear All,
>
> I am a new comer to IDL world. Moreover I am not that good at coding.
> Thus I need your advices,
>
> I want to subset images via the same roi. Images are updated every 10
> minutes or so.
>
> I walked through the previous answers. And they worked fine, how ever
> the subseted image is as big as the first one.
>
> I will paste the code that I combined from web.
> Any help is appreciated
>
> Best REgards
>
> pro sbst_ia_v2
> envi, /restore_base_save_files
> envi_batch_init, log_file='batch.txt'
>
> ; define the image to be opened
> ; pixel size is a function of selevted file
> img_file= 'C:\RSI\IDL61\products\ENVI41\data\can_tmr.img'
> envi_open_file,image_file, r_fid=fid
> ;print,'r_fid=',r_fid,'fid=',fid
> print,'fid=',fid
>
> name='C:\RSI\IDL61\subset_via_roi\roi1.roi'
> envi_restore_rois,name
> roi_ids = envi_get_roi_ids(fid=r_fid)
> roi_addr=envi_get_roi(roi_ids)
>
> print, 'ROI: ', name, n_elements(roi_addr)
> ; check the roi element number
> ;print,'name=',name, ' roi_ids=',roi_ids
>
> ;for j=0,0 Do begin
> roi_data=envi_get_roi_data(roi_ids,fid=fid,pos=[0])
> ; print, 'roi_data'
> ;print, roi_data
> envi_get_roi_information,roi_ids,ns=ns,nl=nl
> print, 'ns= ',ns, '**nl=',nl
> roi_adresses=envi_get_roi(roi_ids)
>
> out_data = intarr(ns,nl)
> out_data [roi_adresses]=roi_data
> ;print, roi_adresses
> ; define the area to map out
> ;yz_data=out_data[195:362,88:173]
> envi_write_envi_file,
> out_data,ns=ns,nl=nl,out_name='out_name',map_info=map_info
> ;endfor
> ;envi_batch_exit
>
>
>
>
> end
|