2012-07-25 2 views
0

IDL 프로그램을 사용하여 ENVI에서 LANDSAT 사진을 공간적으로 서브 세트 화하고 싶습니다. 내가 150 개 이상의 이미지를 가지고 내가 하위 집합을하고 싶습니다, 그래서 배치 모드에서 (아무런 상호 작용없이) 프로그램을 실행하고 싶습니다. 나는 그것을 수동으로하는 방법을 알고 있지만 IDL 코드에서 위도/경도 좌표를 통해 이미지를 공간적으로 부분 집합하는 데 어떤 명령을 사용해야합니까?IDL과 ENVI를 사용하여 일괄 처리 모드로 이미지를 서브 세트하기

답변

2

다음은 하나의 파일에 대한 영감입니다. 파일 이름 목록을 작성하고 반복하여 다수의 파일에 대해 동일한 작업을 수행 할 수 있습니다.

; define the image to be opened (could be in a loop), I believe it can also be a tif, img... 
img_file='path/to/image.hdr' 
envi_open_file,img_file,r_fid=fid 
if (fid eq -1) then begin 
    print, 'Error when opening file ',img_file 
    return 
    endif 

; let's define some coordinates 
XMap=[-70.0580916, -70.5006694] 
YMap=[-32.6030694, -32.9797194] 
; now convert coordinates into pixel position: 
; the transformation function uses the image geographic information: 
ENVI_CONVERT_FILE_COORDINATES, FID, XF, YF, XMap, YMap 
; we must consider integer. Think twice here, maybe you need to floor() or ceil() 
XF=ROUND(XF) 
YF=ROUND(YF) 

; read the image 
envi_file_query, fid, DIMS=DIMS, NB=NB, NL=NL, NS=NS 
pos = lindgen(nb) 
; and store it in an array 
image=fltarr(NS, NL, NB) 
; read each band sequentially 
FOR i=0, NB-1 DO BEGIN 
    image[*,*,i]= envi_get_data(fid=fid, dims=dims, pos=pos[i]) 
endfor 

; simply crop the data with array-indexing function 
imagen= image[XF[0]:XF[1],YF[0]:YF[1]] 

nl2=YF[1]-YF[0] 
ns2=XF[1]-XF[0] 

; read mapinfo to save it in the final file 
map_info=envi_get_map_info(fid=fid) 

envi_write_envi_file, imagen, data_type=4, $ 
    descrip = 'cropped', $ 
    map_info = map_info, $ 
    nl=nl2, ns=ns2, nb=nb, r_fid=r_fid, $ 
    OUT_NAME = 'path/to/cropped.hdr' 
관련 문제