Re: costum stretch an image [message #68805] |
Wed, 02 December 2009 01:15 |
ivitseva
Messages: 15 Registered: December 2009
|
Junior Member |
|
|
On Dec 1, 7:02 pm, jeanh
<jghasb...@DELETETHIS.environmentalmodelers.ANDTHIS.com> wrote:
>> output=interpol(v,x,image)
>> output=round(output)
>> printf,3,'data type = 2'
>
> Hi,
>
> this is a typical data type error.
> round() returns a long by default, so datatype=3
>
> Jean
OH MY....that was it! Such a beginners mistake, but in fact that's
what I am. THANK YOU ALL for answering, you made my day! And thanks
for David, his partitoning I will use for another application I'm
working on. I solved 2 problems at once, what a nice day.
All the best, Eva.
|
|
|
Re: costum stretch an image [message #68811 is a reply to message #68805] |
Tue, 01 December 2009 11:18  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ivitseva wites:
> Thanks for both answers, I worked on it the whole day choosing the
> second option for that seems to be faster and less typing.
Yeah, could have been a mistake. I think I would have
chosen the method that worked. ;-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|
Re: costum stretch an image [message #68812 is a reply to message #68811] |
Tue, 01 December 2009 10:02  |
jeanh
Messages: 79 Registered: November 2009
|
Member |
|
|
> output=interpol(v,x,image)
> output=round(output)
> printf,3,'data type = 2'
Hi,
this is a typical data type error.
round() returns a long by default, so datatype=3
Jean
|
|
|
|
Re: costum stretch an image [message #68814 is a reply to message #68813] |
Tue, 01 December 2009 08:45  |
ivitseva
Messages: 15 Registered: December 2009
|
Junior Member |
|
|
Thanks for both answers, I worked on it the whole day choosing the
second option for that seems to be faster and less typing. In fact it
is fast and does process the image but the output is a "disaster", the
values are there but only part of the image is processed it seems or
in any case the geometry of the resulting image is a mess. The
dimension of the output array is ok so are the projection and datum
information but opening the image it seems that the area is folded or
turned or something...I've never seen that before thus I have no idea
what that problem could be. I could put the input and output onto an
FTP server if needed. In any case here is what I did, can you please
tell me why the output has a messed up geometry?
-----------
pro stretch_idl
indir='X:\run\'
outdir='H:\eva\noaa\phentimesat\'
infile=dialog_pickfile(path=indir,filter='*.bil')
strpos=strpos(infile,'\',/reverse_search)
outfile=strmid(infile,strpos+1,15)
outname=outdir+outfile+'str'+'.bil'
ns=5407
nl=4650
openr,lun,infile,/get_lun
image=fltarr(ns,nl)
readu,lun,image
free_lun,lun
v = [-12, 0, 35, 48] ;--- output values
x = [0., 37., 72., 82.] ;--- input values
output=interpol(v,x,image)
output=round(output)
close, /all
openw,lun, outname, /get_lun
writeu,lun, output
free_lun, lun
close, lun
header=outdir+outfile+'str'+'.hdr'
openw, 3, header
printf,3,'ENVI'
printf,3,'samples ='+STRCOMPRESS(ns)
printf,3,'lines ='+STRCOMPRESS(nl)
printf,3,'bands = 1'
printf,3,'header offset = 0'
printf,3,'file type = ENVI Standard'
printf,3,'data type = 2'
printf,3,'interleave = bsq'
printf,3,'sensor type = AVHRR'
printf,3,'byte order = 0'
printf,3,'map info = {INSPIRE-LAEA, 1.0000, 1.0000, 0.0000, 0.0000,
1.0000000000e+003, 1.0000000000e+003, ETRS89, units=Meters}'
printf,3,'projection info = {11, 6378137.0, 6356752.5, 52.000000,
10.000000, 4321000.0, 3210000.0, ETRS89, INSPIRE-LAEA, units=Meters}'
printf,3,'band names = {sos83}'
CLOSE, 3
print,'Done!'
end
|
|
|
Re: costum stretch an image [message #68880 is a reply to message #68814] |
Mon, 30 November 2009 13:22  |
M. Katz
Messages: 69 Registered: May 2005
|
Member |
|
|
I don't know if the gaps in your almost-piecewise continuous mapping
were intentional, but you could try interpolation. As follows...
v = [-12, 0, 36, 48] ;--- output values
x = [0., 36., 72, 76.021912] ;--- input values
xout = (your input array)
output = interpol( v, x, xout )
and to make it all integers in the end, use either floor() or round(),
as you prefer.
output = floor(interpol( v, x, xout ))
This method also preserves the dimensions of xout in the output array.
It should be very fast.
-M.
|
|
|
Re: costum stretch an image [message #68885 is a reply to message #68880] |
Mon, 30 November 2009 10:16  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ivitseva wites:
> 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...
Here is how I would do a custom stretch of an image in
IDL. I don't know about ENVI. It should be possible to
write this as an ENVI image file, however.
http://www.dfanning.com/code_tips/partition.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|
Re: costum stretch an image [message #68887 is a reply to message #68885] |
Mon, 30 November 2009 10:11  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
ivitseva wites:
> 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...
Humm. I doubt STRETCH_DOIT is the way to go here. I'm not
sure how I would do it in ENVI, but if I were doing this in
IDL, I would use the directions found here.
http://www.dfanning.com/code_tips/partition.html
Presumably once that was done, writing the file as
an ENVI image file would be easy.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|