comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » subset an image by roi in idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
subset an image by roi in idl [message #50330] Mon, 25 September 2006 07:55 Go to next message
gis_learner is currently offline  gis_learner
Messages: 7
Registered: September 2006
Junior Member
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
Re: subset an image by roi in idl [message #50400 is a reply to message #50330] Tue, 03 October 2006 08:00 Go to previous message
peter.eddy@shaw.ca is currently offline  peter.eddy@shaw.ca
Messages: 19
Registered: March 2005
Junior Member
Thanks for your comments/ correction Jean.
This 0,0 / 1,1 difference between IDL and ENVI causes me endless
confusion.
Re: subset an image by roi in idl [message #50468 is a reply to message #50330] Fri, 29 September 2006 10:34 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
> ;Prepare the subset dimensions
> dims[0]=-1L
> dims[1]=min(xf)-1
> dims[2]=max(xf)-1
> dims[3]=min(yf)-1
> dims[4]=max(yf)-1

Do not do the -1 here.
Envi_convert_file_coordinates already returns the pixel locations
starting at 0 and therefore doing -1 induces a shift of 1 pixel in the
subseted image.

This method only returns rectangular subset. You might want to mask the
pixels outside of your polygon.

Jean H.
Re: subset an image by roi in idl [message #50476 is a reply to message #50330] Fri, 29 September 2006 08:45 Go to previous message
peter.eddy@shaw.ca is currently offline  peter.eddy@shaw.ca
Messages: 19
Registered: March 2005
Junior Member
Keep in mind the code above was written by a self taught user, but it
does the trick.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: 3D triangulation of x,y,z vertices
Next Topic: Re: ps file with text

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:41:55 PDT 2025

Total time taken to generate the page: 0.00610 seconds