(Internal) How to export an ENVI display to a new file programmatically
MariM
The below routine can be used to export an ENVI display with overlays. The example is shown for output to JPEG but other formats are also available with different necessary keywords for each type. If you are unsure which keywords are relevant, try using the ENVI export from the display and select the output file format. The dialog should show the available and/or necessary keywords for the file format.
disp_outf_img, dn=dn, out_name=out_name, dims=dims, resolution=resolution,$
rebin=rfact, pixel_border=border, border_val=border_val, ann_names=ann_names, $
vectors=vectors, grid_lines=grid_lines, rois=rois, reg_points=reg_points, contour=contour, $
density_slice=density_slice, class_overlay=class_overlay, in_memory=in_memory, $
c_fac=c_fac, m_fid=m_fid, m_pos=m_pos, m_bg=m_bg, r_fid=r_fid, $
method=method
Keyword description:
dn - display number which is 0-based
out_name - the output file name for the file
dims - output file dimensions
resolution - bit depth of the output file specified as 0-n. See the ENVI output display dialog for the options for the desired output type. The first item in the drop down list would be referenced as '0'.
rebin - output resize factor. Default is 1 (no resize)
pixel_border - 4 element array specifying the size of the border around the image in pixels
border_val - 3 element array specifying the RGB values of the desired background color
ann_names - name of the annotation file to be displayed on the image as a string value
vectors - 0 or 1 for off or on
grid_lines - 0 or 1 for off or on
rois - 0 or 1 for off or on
contour - 0 or 1 for off or on
density_slice - 0 or 1 for off or on
class_overlay - 0 or 1 for off or on
in_memory - 0 or 1 for off or on
c_fac - compression factor between 0 and 1.0 (jpeg only)
m_fid - mask FID
m_pos - mask POS
m_bg - 3 element array for the desired background color in RGB
r_fid - returned file FID
method - output file format options:
0 - ENVI
1 - BMP
2 - PNG
3 - HDF
4 - JPEG
5 - PICT
6 - SRF
7 - TIFF
8 - XWD
9 - ERDAS Imagine
10 - ER Mapper
11 - PIC
12 - ArcVIew
13 - NITF
14 - JPEG 2000
15 - ESRI GRID
Example code:
;using ENVI's sample dataset
file='C:\Program Files\Exelis\ENVI50\classic\data\bhdemsub.img'
; open file which auto-displays into display #1
envi_open_file, file, r_fid=fid
;query the file for needed information
envi_file_query, fid, dims=dims, pos=pos
;display contour vector file
evf_id=envi_evf_open('C:\Testing\contours1.evf')
;bring up vector display widget
vector_display_widget, 0 ;0 references the vector display widget for display #1
;display the vectors on the image
vector_import_from_display, 0, *evf_id ;0 references the display #1
;output display with overlays to a jpeg file
disp_outf_img, dn=0, out_name='c:\test.jpg', dims=dims, resolution=1, rebin=1, vectors=1, in_memory=0, method=4, c_fac=.75
-----------------
Reviewed 8/25/2014 MM