X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



4335 Rate this article:
2.0

ENVI 5: How to incorporate the 'CLASS_DOIT' procedure

The following example code demonstrates how to incorporate the ENVI Classic 'CLASS_DOIT' procedure into the new ENVI 5 programming environment.


pro class_doit_envi5


; Launch ENVI 5

e = ENVI()

;Test file located in the ENVI default data directory

fname='C:\Program Files\ITT\IDL\IDL80\products\envi48\data\bhtmref.img'

; Make sure the file is valid...

envi_open_file, fname, r_fid=fid
if (fid eq -1) then return

;Get some required information from the file for the DOIT routine

envi_file_query, fid, dims=dims, nb=nb, ns=ns, nl=ns

;Band numbers on which to perform the operation
pos=indgen(nb)
; Output file name
out_name='C:\Temp\kmeans_bhtmref.dat'

; Now do the K_Means (method 7) classification
using the Class_Doit
envi_doit,'class_doit', dims=dims, fid=fid, method=7, $
change_thresh= 0.5, num_classes=5, iterations=5, $
pos=pos, out_name=out_name

; **** Set the Display Views ****


;Display the original image in the first View

image = e.OpenRaster(fname)
view1 = e.GetView()
layer1 = view1.CreateLayer(image)
;Set up some properties for this View
;...stretch 'property to 2%
layer1.quick_stretch='linear 2%'

;Create the second View which will contain the K-Means output

view2 = e.CreateView()

;Create the variable for the output

kmeans=e.OpenRaster(out_name)

;Now create the ENVIRasterLayer

layer2=view2.Createlayer(kmeans)

; Need to put final views here to have them at the resized

; to full extent
view1.Zoom, /full_extent
view2.Zoom, /full_extent



END

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »