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

Home » Public Forums » archive » costum stretch an image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
costum stretch an image [message #68888] Mon, 30 November 2009 09:57
ivitseva is currently offline  ivitseva
Messages: 15
Registered: December 2009
Junior Member
Good mornig or evening everybody. I'm trying to solve this stretching
issue for some time now, my attempts resulted in a huge mess...Please
help!
I'd like to stretch an image of 1 band using IDL or ENVI stretch_doit,
whatever is the fastest. I need to script it for I'll need to do it
with a huge number of images.
My image is a floating point, the input range of values is 0.000000 to
76.021912 and the output should be integer.
Now, the values 0.000000 till 36.0000 should be stretched into a range
of -12 to -1, the values in the range of 37.0000 till 72.0000 should
be stretched into a range of 0 till 36, and the values from 72.000000
till 76.021912 should be in the range of 37 to 48.
This might be a piece of cake but I just cannot manage it. I had tried
to do it with stretch_doit but not being a programmer I am stuck with
this quite easy task...so here is what I did till now but it is
completely wrong for all these else-es and endelse-es and if-s and
endif-s are wrong...
--------------
pro stretch_doit
envi, /restore_base_save_files

envi_batch_init, log_file='batch.txt'
indir='H:\eva\noaa\phentimesat\'
infile=dialog_pickfile(path=indir,filter='.bil')
envi_open_file, infile, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif

bname=file_basename(infile,'.bil')
outfile=bname+'str'+'.bil'

envi_file_query, fid, dims=dims, nb=nb

phe=envi_get_data(fid=fid, dims=dims, pos=0)

if phe lt 37.000000 then begin

envi_doit, 'stretch_doit', fid=fid, pos=0, dims=dims, method=1,
i_min=0.000000, i_max=36.000000,$
range_by=1, out_min=-12, out_max=0, out_dt=2, r_fid=sfid1,/
in_memory
endif else begin
if phe ge 37.00000 and phe le 72.000000

envi_doit,'stretch_doit',fid=fid,pos=0,dims=dims,method=1,i_ min=37.000000,
i_max=72.000000,$
range_by=1, out_min=0, out_max=36, out_dt=2, r_fid=sfid2,/
in_memory
endif
endelse
else begin

envi_doit,'stretch_doit',fid=fid,pos=0,dims=dims,method=1,i_ min=38.000000,
i_max= 76.021912,$
range_by=1, out_min=37, out_max=48, out_dt=2, r_fid=sfid3,/
in_memory
endelse
endelse

outfid=[sfid1,sfid2,sfid3]

phestr=envi_get_data(fid=outfid, dims=dims,pos=0)
ENVI_WRITE_ENVI_FILE, phestr, out_name=outfile,data_type=2

envi_batch_exit
end

----------------
I also tried to define ranges like below but then I don't know how to
go on:

low=where(phe lt 37.000000)
middle=where(phe ge 37.000000 and phe le 72.000000)
high=where(phe gt 72.000000 and le 76.021912)
[Message index]
 
Read Message
Previous Topic: SHAPEFILE changes in IDL7.1?
Next Topic: Unexpected array subscript truncation

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

Current Time: Wed Oct 08 15:52:14 PDT 2025

Total time taken to generate the page: 0.00387 seconds