0

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:

pro correct_reflec 

fname='D:\Quick\BA.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 
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 
paisanco
  • 4,098
  • 6
  • 27
  • 33
user30985
  • 573
  • 1
  • 6
  • 19

1 Answers1

1

You are missing a ":" in the ELSE clause of the third CASE statement. Is that where the syntax error is showing?

mgalloy
  • 2,356
  • 1
  • 12
  • 10
  • After adding a ":", the syntax error is still showing all the CASE statement. – user30985 Jul 15 '14 at 04:59
  • % Syntax error. b1 ge 10000: br(*,0,*)= (b1)* 1 ^ % Syntax error. else: br(*,0,*)= b1*float(b1)/(10000) ^ % Syntax error. – user30985 Jul 15 '14 at 08:15
  • You also have "foat" instead of "float" a few places ... Or is that a copying error? – Ajean Jul 15 '14 at 11:07
  • Adding the `:` makes my version compile. I always find using `compile_opt stricter` helps these add syntax errors. How about [this](http://michaelgalloy.com/wp-content/uploads/2014/07/correct_reflec.pro) version? – mgalloy Jul 15 '14 at 19:50