You will not be able to successfully use Band Math to return the maximum value from a layer stack of NDVI images. This is due to how Band Math retrieves data from an image and calculates values (in a block rather than pixel by pixel). There is a programmatic alternative, though. Below is an example program that should do what you want, but you will have to place it into a .pro file in IDL and then place that file in the SAVE_ADD directory of your ENVI installation. It requires that you have ENVI+IDL, not just ENVI.
====================
;+
;create_composite.pro
;
;This program is designed to create a new "composite" image based on multiple band input.
;The entire spectrum for each pixel is examined to determine the new value to place in
;the corresponding pixel of the composite image. The examination methods are minimum value,
;maximum value, and mean value.
;
;This program is not officially supported by ITT-VIS Technical Support and is not guaranteed to work with versions of ENVI
;beyond 4.3.
;
;Author: Devin Alan White, ITT-VIS Technical Support
;Email: dwhite@ittvis.com
;Date: 09/22/2006
;-
pro create_composite_define_buttons, buttonInfo
compile_opt idl2
;Create button so that the program can be called from within ENVI.
;Button will appear under File->Basic Tools->Create Composite.
envi_define_menu_button, buttonInfo, value = 'Create Composite', $
event_pro='create_composite', POSITION='last', ref_value = 'Basic Tools', $
uvalue='Create Composite'
end
pro composite_functions, fid, pos, max_val=max_val, min_val=min_val, mean_val=mean_val
compile_opt idl2
envi_file_query, fid, ns=ns, nl=nl, nb=nb, data_type=dt, dims=dims
inherit = envi_set_inheritance(fid, dims, /spatial)
;Create output file
output_file = dialog_pickfile(title='Select Output File Name and Location')
if output_file eq '' then return
openw, lun, output_file, /get_lun
if keyword_set(max_val) then begin
envi_report_init, title='Maximum Value Composite Image Creation', $
['Accessing data from original file...','Creating Composite Image...'], $
base=base, /interrupt
envi_report_inc, base, nl-1
;Set up for loop to grab data slices in BIP interleave
for i=0, nl-1 do begin
envi_report_stat, base, i, nl-1, cancel=cancel
if cancel eq 1 then begin
envi_report_init, base=base, /finish
free_lun, lun
file_delete, output_file
return
endif
slice = envi_get_slice(fid=fid, line=i, pos=pos, $
xs=0, xe=ns-1, /bip)
;Set up for loop to grab maximum value for each pixel and place
;it in a new file at the same spatial location
for j=0, ns-1 do begin
max_value = max(slice[*,j])
writeu, lun, max_value
endfor
endfor
envi_report_init, base=base, /finish
envi_setup_head, inherit=inherit, nb=1, data_type=dt, fname=output_file, $
interleave=0, ns=ns, nl=nl, offset=0, /write
endif
if keyword_set(min_val) then begin
envi_report_init, title='Minimum Value Composite Image Creation', $
['Accessing data from original file...','Creating Composite Image...'], $
base=base, /interrupt
envi_report_inc, base, nl-1
;Set up for loop to grab data slices in BIP interleave
for i=0, nl-1 do begin
envi_report_stat, base, i, nl-1, cancel=cancel
if cancel eq 1 then begin
envi_report_init, base=base, /finish
free_lun, lun
file_delete, output_file
return
endif
slice = envi_get_slice(fid=fid, line=i, pos=pos, $
xs=0, xe=ns-1, /bip)
;Set up for loop to grab minimum value for each pixel and place
;it in a new file at the same spatial location
for j=0, ns-1 do begin
min_value = min(slice[*,j])
writeu, lun, min_value
endfor
endfor
envi_report_init, base=base, /finish
envi_setup_head, inherit=inherit, nb=1, data_type=dt, fname=output_file, $
interleave=0, ns=ns, nl=nl, offset=0, /write
endif
if keyword_set(mean_val) then begin
envi_report_init, title='Mean Value Composite Image Creation', $
['Accessing data from original file...','Creating Composite Image...'], $
base=base, /interrupt
envi_report_inc, base, nl-1
;Set up for loop to grab data slices in BIP interleave
for i=0, nl-1 do begin
envi_report_stat, base, i, nl-1, cancel=cancel
if cancel eq 1 then begin
envi_report_init, base=base, /finish
free_lun, lun
file_delete, output_file
return
endif
slice = envi_get_slice(fid=fid, line=i, pos=pos, $
xs=0, xe=ns-1, /bip)
slice = float(slice)
;Set up for loop to grab mean value for each pixel and place
;it in a new file at the same spatial location
for j=0, ns-1 do begin
mean_value = mean(slice[*,j])
writeu, lun, mean_value
endfor
endfor
envi_report_init, base=base, /finish
envi_setup_head, inherit=inherit, nb=1, data_type=4, fname=output_file, $
interleave=0, ns=ns, nl=nl, offset=0, /write
endif
free_lun, lun
envi_open_file, output_file
end
pro create_composite, event
compile_opt idl2
;Prompt user to select input file
envi_select, fid=input_fid, /file_only, pos=pos, $
title='Select Input File for Composite Generation', $
/no_dims
if (input_fid[0] eq -1) then return
;Create widget to facilitate method selection
base = widget_auto_base(title='Type?')
list = ['Minimum Value', 'Maximum Value', 'Mean Value']
choice = widget_menu(base, list=list, /excl, /auto, uvalue='choice', rows=3)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
;Call composite program based on user choice
if result.choice eq 0 then begin
composite_functions, input_fid, pos, /min_val
endif
if result.choice eq 1 then begin
composite_functions, input_fid, pos, /max_val
endif
if result.choice eq 2 then begin
composite_functions, input_fid, pos, /mean_val
endif
end
|