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

Home » Public Forums » archive » shape
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
shape [message #75621] Wed, 16 March 2011 00:46
gaurijyoti29 is currently offline  gaurijyoti29
Messages: 10
Registered: April 2009
Junior Member
The following code is leaving some blank space at the center of output
file. I would request you all to just have a look on code please
suggest me how to fix. The input image(6197x5289) is in UTM WGS84 ZONE
45 and evf file is also in same format. I would appreciate your
valuable suggestions;

evf_id = envi_evf_open(input_folder+'polygon.evf')
envi_evf_info, evf_id, num_recs=num_recs, $
data_type=data_type, projection=projection, $
layer_name=layer_name
;*******************************************************
envi_open_file, input_folder + file1.img , r_fid=fid
envi_file_query, fid, ns=ns, nl=nl, nb=nb
pos=lindgen(nb)
file_out = input_folder + file2.img

min_x = ns & min_y = nl
max_x = 0 & max_y = 0

map_info = envi_get_map_info(fid=fid)

out_data = intarr(ns,nl) ; Create the "black" image"
out_data [*,*] = 0 ;Assign a value to all the pixels of the
;out image so that their values will
not be
;"similar" to the values that you
extract from the ROI
temp_data=intarr(ns,nl) - 0

roi_id = ENVI_CREATE_ROI(ns=ns, nl=nl, color=4, name='shape')

FOR i=0,num_recs-1 DO BEGIN
; read the record
;
vec = ENVI_EVF_READ_RECORD(evf_id, i)
xmap= vec(0,*)
ymap= vec(1,*)
;just to verify
;print, 'Number of Records ' + ': ', num_recs
;print, 'Number of nodes in Record ' + $
; strtrim(i+1,2) + ': ', n_elements(vec[0,*])

envi_convert_file_coordinates, fid, xf, yf, xmap, ymap

; Get the minimum and maximum x and y values of points inside the
vector

temp_min_x = min (xf) & temp_max_x = max(xf)
temp_min_y = min (yf) & temp_max_y = max(yf)

if temp_min_x lt min_x then min_x = temp_min_x
if temp_min_y lt min_y then min_y = temp_min_y
if temp_max_x gt max_x then max_x = temp_max_x
if temp_max_y gt max_y then max_y = temp_max_y

ENVI_DEFINE_ROI, roi_id, xpts=REFORM(xf, /over), $
ypts=REFORM(yf, /over), /polygon

;*********************************************************** ********
roi_data = ENVI_GET_ROI_DATA( roi_id, fid=fid, pos = [0])
ENVI_GET_ROI_INFORMATION, roi_id, ns=ns, nl=nl
roi_addresses = ENVI_GET_ROI(roi_id) ; Get the "position" of the
pixels in the ROI
temp_data[roi_addresses] = roi_data ; Assign values to the pixels
of the output image that are in the ROI
out_data[*,*] = temp_data
temp_data = intarr(ns,nl) - 0
;*********************************************************** ********************
ENDFOR
; Make a buffer of 2 "blank" pixels around the resized image
min_x = fix(min_x) & min_y = fix (min_y)
max_x = fix(max_x) & max_y = fix (max_y)
envi_convert_file_coordinates, fid, min_x, min_y, xnew, ynew,/to_map
map_info.mc[2]= xnew
map_info.mc[3]= ynew
outdata=out_data[min_x:max_x, min_y:max_y]
ENVI_WRITE_ENVI_FILE, outdata,out_dt=2,out_name=file2.img,
map_info=map_info
envi_file_mng,id= fid, /remove
envi_file_mng,id= roi_id, /remove
endfor
envi_evf_close, evf_id
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Non-blocking read
Next Topic: sky is falling, again ?

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

Current Time: Wed Oct 08 16:12:33 PDT 2025

Total time taken to generate the page: 0.00857 seconds