CGIMAGE
The purpose of cgIMAGE is to create a device-independent TV command
with the power and functionality to be used in sophisticated graphics
programs, as well as at the IDL command line. It can be thought of as
a "smart" TV command.
There is a common block in cgImage that is defined as follows upon exiting
this command::
COMMON FSC_$CGIMAGE, $
_cgimage_xsize, $ ; The X size of the image.
_cgimage_ysize, $ ; The Y size of the imge.
_cgimage_winxsize, $ ; The X size of the window displaying the image.
_cgimage_winysize, $ ; The Y size of the window displaying the image.
_cgimage_position, $ ; The final position of the image in the window.
_cgimage_winID, $ ; The window index number of the window displaying the image.
_cgimage_current ; Set to 1 if a call to cgImage is made.
Categories
Graphics
Examples
To display an image with a contour plot on top of it, type::
filename = FILEPATH(SUBDIR=['examples','data'], 'worldelv.dat')
image = BYTARR(360,360)
OPENR, lun, filename, /GET_LUN
READU, lun, image
FREE_LUN, lun
thisPostion = [0.1, 0.1, 0.9, 0.9]
cgIMAGE, image, POSITION=thisPosition, /KEEP_ASPECT_RATIO
CONTOUR, image, POSITION=thisPosition, /NOERASE, XSTYLE=1, $
YSTYLE=1, XRANGE=[0,360], YRANGE=[0,360], NLEVELS=10
To display four images in a window without spacing between them::
!P.Multi=[0,2,2]
cgImage, image, Margin=0
cgImage, image, Margin=0
cgImage, image, Margin=0
cgImage, image, Margin=0
!P.Multi = 0
To display four image in a window with associated color bars::
!P.Multi=[0,2,2]
p = [0.02, 0.3, 0.98, 0.98]
LoadCT, 0
cgImage, image, Position=p
cgColorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
p = [0.02, 0.3, 0.98, 0.98]
LoadCT, 2
cgImage, image, Position=p
cgColorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
p = [0.02, 0.3, 0.98, 0.98]
LoadCT, 3
cgImage, image, Position=p
cgColorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
p = [0.02, 0.3, 0.98, 0.98]
LoadCT, 5
cgImage, image, Position=p
cgColorbar, Position=[p[0], p[1]-0.1, p[2], p[1]-0.05]
!P.Multi =0
To set a missing value to -32767 and the color white and do
a 3% histogram clip of the image::
cgLoadCT, 4, /Brewer, NColors=254
TVLCT, palette, /Get
cgImage, image, Missing_Value=-32767, Missing_Color='white', Stretch='Clip', Clip=3
Author
FANNING SOFTWARE CONSULTING::
David W. Fanning
1645 Sheely Drive
Fort Collins, CO 80526 USA
Phone: 970-221-0438
E-mail: david@idlcoyote.com
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
History
Modification History
Written by: David W. Fanning, from modifications to TVIMAGE. 3 Feb 2011.
8 Feb 2011. Added OPOSITION keyword. DWF.
27 Feb 2011. Added keywords to make cgImage more compatible with TVImage calls. DWF.
Color table vectors must be obtained AFTER loading the color palette. 6 March 2011. DWF.
I have been convinced (conversations with Wayne Landsman) that if the
CENTER keyword is set, the MINUS_ONE keyword is not needed, since
it was created to solve the same problem. So, I have changed the
default setting of MINUS_ONE to 0. 14 March 2011. DWF.
Corrected a problem with restoring color tables if a PALETTE is used. 31 March 2011. DWF.
Whoops! Documented a CHARSIZE keyword, but forgot to define it. 7 July 2011.
Damnation! I did the same thing with the FONT keyword! 25 July 2011.
And now a TITLE keyword! What the devil is going on!? 29 Aug 2011.
Very slight modifications to image size and start position so that the image is
positioned completely inside the axes. 30 Sept 2011. DWF.
Fitting the image inside the axes causes image matching problems (and lines!) in
other programs, so I've decided to only do positioning inside axes when the
user asks for this capability by setting the new FIT_INSIDE keyword. 16 Nov 2011. DWF.
Problem with transparent images with alpha channels caused by changes in the TVImage->cgImage
transition. Added AlphaFGPosition keyword to address issues. Cleaned up the
code and improved the internal documentation. 22 Nov 2011. DWF.
Added the ability to stretch 2D image arrays in various ways before display. 1 Dec 2011.
Added the ability to handle missing data in 2D arrays before display. 1 Dec 2011.
Added a DISPLAY keyword to display the image in windows with the image aspect ratio. 2 Dec 2011.
Added the ability to send the output directly to a file via the OUTPUT keyword. 9 Dec 2011, DWF.
PostScript, PDF, and Imagemagick parameters can now be tailored with cgWindow_SetDefs. 14 Dec 2001. DWF.
Modified to use cgDefaultColor for default color selection. 24 Dec 2011. DWF.
Changes to allow better default colors, based on changes to cgColor and cgDefaultColor. 1 Feb 2012. DWF.
I was passing the wrong MINVALUE and MAXVALUE values to the scaling function. 12 Feb 2012. DWF.
I made cgImage aware of a "feature" of MAP_SET that sets !P.MULTI[0]=-1, which was screwing
up the algorithm to cause cgImage to erase the display window. 28 Feb 2012. DWF.
Added a Standard Deviation stretch, including the EXCLUDE and MULTIPLIER keywords to the
SDevScl command. 6 June 2012. DWF.
Now saving the image POSITION in FSC_$CGIMAGE common block, even if in PostScript, because other
routines (e.g., cgMap) may depend on it (e.g., using ONIMAGE keyword). 26 July 2012. DWF.
Added the ability to use escape characters in plot titles to specify cgSymbol symbols. 27 July 2012. DWF.
Copyright
Copyright (c) 2011-2012, Fanning Software Consulting, Inc.