I am trying to create a ROI file from bhtmref.img using ENVI 5.2. I clicked on the ROI tool, chose a Rectangular geometry with both Multi Part and Vertex Snap unchecked. I drew the rectangle and chose "Accept Rectangle". Then in the ROI Tool window, I chose File | Export | Export to Classic, and saved as bhtm_nd.roi.
I then ran the following neural network program on IDL 8.4, and got the solid colored ROI shape with no map features for testimg. I don't think that is what it should be, and I think it is because I did not create the ROI file correctly.
forward_function envi_get_roi_ids, envi_get_roi_dims_ptr
pro neural_network_example
; Restore all the base save files.
envi, /restore_base_save_files
; Initialize ENVI and send all errors and warnings tobatch.txt
envi_batch_init, log_file=’batch.txt’
; Open the input file
file = 'bmthref.img'
envi_open_file, file, r_fid=fid
if (fid eq-1) then begin
print, ‘Error opening file ’, file
envi_batch_exit
return
endif
; Set the dims and pos to classify all data (spatiallyand spectrally) in the file
envi_file_query, fid, ns=ns, nb=nb
pos = lindgen(nb)
out_name = ‘testimg’
rule_out_name = ''
; Restore the ROI file used as the training pixels.
; Each ROI in the file will be considered an input class.
envi_restore_rois, ‘bhtm_nd.roi’
roi_ids = envi_get_roi_ids(fid=fid, roi_colors=lookup,roi_names=class_names)
; Specify the neural net training criteria.
theta = 0.9
eta = 0.2
alpha = 0.9
act_type = 0
ams_crit = 0.1
num_layers = 3
num_sweeps = 1000
; Set the classification variables
num_classes = n_elements(roi_ids)
class_names = [‘Unclassified’, class_names]
lookup =reform([0, 0, 0, reform(lookup, 3*num_classes)], num_classes+1)
; Call thedoit
envi_doit, ‘envi_neural_net_doit’, fid=fid, pos=pos, dims=dims,out_name=out_name, rule_out_name=’’, $
theta=theta,eta=eta, alpha=alpha, num_classes=num_classes, num_sweeps=num_sweeps,num_layers=num_layers, $
act_type=act_type, rms_crit=rms_crit, roi_ids=roi_ids, /train,class_name=class_names, lookup=lookup
; Exit ENVI
envi_batch_exit
end
|