Normalize image after running FLAASH [message #88999] |
Sun, 13 July 2014 20:42  |
phamlien24
Messages: 6 Registered: July 2014
|
Junior Member |
|
|
pro correct_reflec
fname='D:\Quick\BAoct25_p004_R2C3_rad.dat'
envi_open_file, fname, r_fid=fid,NO_REALIZE=1
ENVI_FILE_QUERY,fid,DIMS=dims,NS=ns,NL=nl,NB=nb, pos=pos
Hi,
I had a Quickbird image and after running the FLAASH, I would like to normalize the image as following: if the pixel>0 or =10000, multiply it by 1; if pixel < or = 0 multiple it by 0; if pixel >0 and <10000 multiple it by its float value and devide the result by 10 000.
I wrote the IDL code as following, but my conditional statement is error. Could you please help me to fix the conditional statement.
Thanks so much for your help.
Lien
My IDL code:
"map_info=envi_get_map_info(fid=fid)
b1 = ENVI_GET_DATA(FID=fid, dims=dims, pos=1)
ns=n_elements(b1[*,0])
nl=n_elements(b1[0,*])
br=fltarr(ns,3,nl)
CASE 1 of
b1 le 0: br(*,0,*) = (b1)*0
b1 ge 10000: br(*,0,*)= (b1)* 1
else: br(*,0,*)= b1*foat(b1)/(10000)
ENDCASE
b2 = ENVI_GET_DATA(FID=fid, dims=dims, pos=1)
CASE 1 of
b2 le 0: br(*,1,*) = b2*0
b2 ge 10000:br(*,1,*)=b2*1
else: br(*,1,*)=b2*foat(b2)/10000
ENDCASE
b3 = ENVI_GET_DATA(FID=fid, dims=dims, pos=2)
CASE 1 of
b3 le 0:br(*,2,*) = b3*0
b3 ge 10000: br(*,2,*)=b3*1
else br(*,2,*)=b3*foat(b3)/10000
ENDCASE
envi_write_envi_file, br, map_info=map_info, out_name='D:\Quick\test', r_fid=fid
END
|
|
|
|
Re: Normalize image after running FLAASH [message #89010 is a reply to message #89006] |
Mon, 14 July 2014 22:06   |
phamlien24
Messages: 6 Registered: July 2014
|
Junior Member |
|
|
On Tuesday, 15 July 2014 11:00:32 UTC+12, Phillip Bitzer wrote:
> On Sunday, July 13, 2014 10:42:05 PM UTC-5, phaml...@gmail.com wrote:
>
> Thanks for your comments. After I correct "foat" into "float" and running the IDL, the error is:
% 12 Compilation error(s) in module CORRECT_REFLEC.
% Attempt to call undefined procedure/function: 'CORRECT_REFLEC'.
% Execution halted at: $MAIN$
>> I wrote the IDL code as following, but my conditional statement is error. Could you please help me to fix the conditional statement.
>
>>
>
>
>
> Well, you didn't tell us what the error is, so here goes nothing:
>
>
>
> In all three "ELSE"'s, you have "foat". I suppose you want "fLoat" there.
|
|
|
Re: Normalize image after running FLAASH [message #89011 is a reply to message #89006] |
Tue, 15 July 2014 01:20   |
phamlien24
Messages: 6 Registered: July 2014
|
Junior Member |
|
|
On Tuesday, 15 July 2014 11:00:32 UTC+12, Phillip Bitzer wrote:
> On Sunday, July 13, 2014 10:42:05 PM UTC-5, phaml...@gmail.com wrote:
> Thanks for your comments. After I correct "foat" into "float", it still has error.
as following:
b1 le 0: br(*,0,*) = (b1)*0
^
% Syntax error.
b1 ge 10000: br(*,0,*)= (b1)* 1
^
% Syntax error.
else: br(*,0,*)= b1*float(b1)/(10000)
^
% Syntax error.
b2 le 0: br(*,1,*) = b2*0
^
% Syntax error.
b2 ge 10000:br(*,1,*)=b2*1
^
% Syntax error.
else: br(*,1,*)=b2*float(b2)/10000
^
% Syntax error.
b3 le 0:br(*,2,*) = b3*0
^
% Syntax error.
b3 ge 10000: br(*,2,*)=b3*1
^
% Syntax error.
else: br(*,2,*)=b3*float(b3)/10000
% Syntax error.
% 12 Compilation error(s) in module CORRECT_REFLEC.
% Attempt to call undefined procedure/function: 'CORRECT_REFLEC'.
% Execution halted at: $MAIN$
>
>
>>
>
>> I wrote the IDL code as following, but my conditional statement is error. Could you please help me to fix the conditional statement.
>
>>
>
>
>
> Well, you didn't tell us what the error is, so here goes nothing:
>
>
>
> In all three "ELSE"'s, you have "foat". I suppose you want "fLoat" there.
|
|
|
|
Re: Normalize image after running FLAASH [message #89021 is a reply to message #89016] |
Tue, 15 July 2014 20:28  |
pthlien
Messages: 1 Registered: July 2014
|
Junior Member |
|
|
On Wednesday, July 16, 2014 12:52:55 AM UTC+12, Josh Sixsmith wrote:
> Well your example of CASE isn't a single value for comparing which CASE to evaluate. You've got an entire array ie "b3 le 0".
>
>
>
> Take a look at the example in the help file:
>
>
>
> http://www.exelisvis.com/docs/CASE.html
>
>
>
> It's a single evaluation.
>
>
>
> As for other parts of your code.
>
> You've already retrieved the "number of samples (the ns variable)" and the "number of lines" (nl) from you call to "ENVI_FILE_QUERY", so you can probably leave out the lines where you redefine them.
>
>
>
> Also, I may be wrong, but "b1*float(b1)/10000 doesn't sound like normalizing your data. A value of 9000 now becomes 8100. It sounds like you just need to apply a scale factor in which case just do "b1 / 10000.0"
>
>
>
> Back to dealing with your different cases, of "LE 0", "GE 10000" etc, just evaluate the array in a series of complement expressions that account for you different cases.
>
>
>
> result = (b1 le 0) * 0 + (b1 ge 10000) * 10000 + ((b1 gt 0) and (b1 lt 10000) * (b1 / 10000)
>
>
>
> That might get you what you're after. It'll use a lot of memory in IDL though. Seeing as you're using ENVI try the 'MATH_DOIT" rountine, and ENVI will tile your data automatically.
>
>
>
> Hope that helps
>
>
>
> Josh
Thanks Josh so much. It works after I corrected following your advice and the syntax error I got corrected by br[...]=..., not br(...)=
Lien
|
|
|