Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: problem wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 18 Topic 5562 of 6457
Post > Topic >>

Re: problem with subset one image by another

by Jean H <jghasban@[EMAIL PROTECTED] > Mar 27, 2008 at 09:56 AM

negra wrote:
>> Without more details about what you want to do it is difficult,
>> bordering upon impossible, for us to give you any useful advice about
>> how to do it.
> 
> here is idl routine what I written. The beginning of it, is working.
> pro spat_subset
> cd, 'C:\Scandata\L1a'
> HKMfiles = FILE_SEARCH('MOD02HKM.*.img',count=numfiles)
> PRINT, '# NDSI files:',N_ELEMENTS(FILE_SEARCH('MOD02HKM.*.img'))
> print, FILE_SEARCH(HKMfiles)
> for j=0,numfiles-1 DO BEGIN
> HKM_name = HKMfiles[j]
> print,HKM_name
> ;first restore all base save files
> ;
> envi, /restore_base_save_files
> ;
> ;Initialize ENVI and send all errors and warnings to the file
> batch.txt
> ;
> envi_batch_init, log_file='batch.txt'
> ;
> ;Open the input files
> ;kz_hkm mask file
> envi_open_file, 'C:\Scandata\L1A\mask\kz_hkm', r_fid=file1_fid
> if (file1_fid eq -1) then begin
>      envi_batch_exit
>      return
> endif
> envi_open_file,'C:\Scandata\L1A\'+ HKMfiles[j], r_fid=file_fid
> if (file_fid eq -1) then begin
>      envi_batch_exit
>      return
> endif
> envi_file_query, file1_fid, dims=file1_dims, ns=file1_ns, nl=file1_nl,
> nb=file1_nb
> file1_dims = [-1L,0,file1_ns-1,0,file1_nl-1]
> file1_mapinfo = envi_get_map_info(fid=file1_fid)
> print, file1_mapinfo
> file1_xf = [0,file1_ns-1]
> file1_yf = [0,file1_nl-1]
> envi_convert_file_coordinates, file1_fid, file1_xf, file1_yf,
> file1_xmap, file1_ymap, /to_map
> print, 'UL corner:',file1_xmap[0],file1_ymap[0]
> print, 'LR corner:',file1_xmap[1],file1_ymap[1]
> ;Longitude 44.39011111 - 88.38219444
> ;Latitude 36.20264722 - 56.35832500
> ;subset #1
> 
> envi_file_query, file_fid, dims=file_dims, ns=file_ns, nl=file_nl,
> nb=file_nb
> file_dims = [-1L,0,file_ns-1,0,file_nl-1]
> file_mapinfo = envi_get_map_info(fid=file_fid)
> print, file_mapinfo
> pos  = lindgen(file_nb)
> out_namea = HKMfiles[j]+'subset.img'
> file_mapinfo = envi_get_map_info(fid=file_fid)
> _xfactor = file1_mapinfo.ps[0]/file_mapinfo.ps[0]
> _yfactor = file1_mapinfo.ps[1]/file_mapinfo.ps[1]
> print, [_xfactor, _yfactor]
> 
> file_xf = [0,file_ns-1]
> file_yf = [0,file_nl-1]
> envi_convert_file_coordinates, file_fid, file_xf, file_yf, file_xmap,
> file_ymap, /to_map


you have to do the opposite: take the projected coordinates of the mask 
image, and convert it to the Cartesian coordinate of the image to subset.

then, don't do the "resize", as you are just changing the pixel size and 
not the covered area.  do subset = 
image[maskXmin:maskXmax,maskYmin:maskYmax]

Jean


> print, 'UL corner:',file_xmap[0],file_ymap[0]
> print, 'LR corner:',file_xmap[1],file_ymap[1]
> ;Longitude 63.29925556 - 106.42788056
> ;Latitude 42.01251944 - 64.14574167
> ; I have coordinates of image corners
> 
> ;--------------------------------------
> ;here I think must have somthing like this, but I'm not sure
> if  file_xmap[0]< file1_xmap[0]then file1_xmap[0] else file_xmap[0]
> if  file_xmap[1]> file1_xmap[1]then file1_xmap[1] else file_xmap[1]
> if  file_ymap[0]< file1_ymap[0]then file1_ymap[0] else file_ymap[0]
> if  file_ymap[1]> file1_ymap[1]then file1_ymap[1] else file_ymap[1]
> then I think must been calculation number of pixels
> 
> ;-----------------------------------------------------
> envi_doit, 'resize_doit', $
>     fid=file_fid, pos=pos, dims=file_dims, interp=0, rfact=[_xfactor,
> _yfactor], $
>     out_name=out_namea, r_fid=file2_fid
> endfor
> end
 




 18 Posts in Topic:
problem with subset one image by another
chemsat@[EMAIL PROTECTED]  2008-03-22 02:49:18 
Re: problem with subset one image by another
David Fanning <news@[E  2008-03-22 10:12:46 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-26 09:47:21 
Re: problem with subset one image by another
James Kuyper <jameskuy  2008-03-26 19:52:59 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-26 19:10:09 
Re: problem with subset one image by another
James Kuyper <jameskuy  2008-03-27 11:40:28 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-27 05:47:07 
Re: problem with subset one image by another
James Kuyper <jameskuy  2008-03-27 13:54:49 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-27 08:40:16 
Re: problem with subset one image by another
Jean H <jghasban@[EMAI  2008-03-27 09:56:34 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-28 08:30:05 
Re: problem with subset one image by another
Jean H <jghasban@[EMAI  2008-03-28 10:22:13 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-03-28 18:54:37 
Re: problem with subset one image by another
Jean H <jghasban@[EMAI  2008-03-31 11:05:21 
Re: problem with subset one image by another
James Kuyper <jameskuy  2008-04-01 11:18:11 
Re: problem with subset one image by another
Bulrush <Wasit.Weather  2008-03-28 21:18:27 
Re: problem with subset one image by another
negra <chemsat@[EMAIL   2008-04-04 08:32:13 
Re: problem with subset one image by another
Bulrush <Wasit.Weather  2008-04-04 08:54:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 21:31:06 CST 2008.