IMDISP Name
IMDISP Purpose
Display an image on the current graphics device.
IMDISP is an advanced replacement for TV and TVSCL.
- Supports WIN, MAC, X, CGM, PCL, PRINTER, PS, Z and METAFILE graphics
devices,
- Image is automatically byte-scaled (can be disabled),
- Custom byte-scaling of Pseudo color images via the RANGE keyword,
- Pseudo (indexed) color and True color images are handled automatically,
- 8-bit and 24-bit graphics devices are handled automatically,
- Decomposed color settings are handled automatically,
- Image is automatically sized to fit the display (can be disabled),
- The !P.MULTI system variable is honored for multiple image display,
- Image can be positioned via the POSITION keyword,
- Color table splitting via the BOTTOM and NCOLORS keywords,
- Image aspect ratio customization via the ASPECT keyword,
- Resized images can be resampled (default) or interpolated,
- Top down image display via the ORDER keyword (!ORDER is ignored),
- Selectable display channel (R/G/B) via the CHANNEL keyword,
- Background can be set to a specified color via the BACKGROUND keyword,
- Screen can be erased prior to image display via the ERASE keyword,
- Plot axes can be drawn on the image via the AXIS keyword,
- Photographic negative images can be displayed via the NEGATIVE keyword.
Category
Image display
Calling Sequence
IMDISP, IMAGE
Inputs
IMAGE Array containing image data.
Pseudo (indexed) color images must have 2 dimensions.
True color images must have 3 dimensions, in either
[3, NX, NY], [NX, 3, NY], or [NX, NY, 3] form.
Optional Inputs
None.
Keyword Parameters
RANGE For Pseudo Color images only, a vector with two elements
specifying the minimum and maximum values of the image
array to be considered when the image is byte-scaled
(default is minimum and maximum array values).
This keyword is ignored for True Color images,
or if the NOSCALE keyword is set.
BOTTOM Bottom value in the color table to be used
for the byte-scaled image
(default is 0).
This keyword is ignored if the NOSCALE keyword is set.
NCOLORS Number of colors in the color table to be used
for the byte-scaled image
(default is !D.TABLE_SIZE - BOTTOM).
This keyword is ignored if the NOSCALE keyword is set.
MARGIN A scalar value specifying the margin to be maintained
around the image in normal coordinates
(default is 0.1, or 0.025 if !P.MULTI is set to display
multiple images).
INTERP If set, the resized image will be interpolated using
bilinear interpolation
(default is nearest neighbor sampling).
DITHER If set, true color images will be dithered when displayed
on an 8-bit graphics device
(default is no dithering).
ASPECT A scalar value specifying the aspect ratio (height/width)
for the displayed image
(default is to maintain native aspect ratio).
POSITION On input, a 4-element vector specifying the position
of the displayed image in the form [X0,Y0,X1,Y1] in
in normal coordinates
(default is [0.0,0.0,1.0,1.0]).
See the examples below to display an image where only the
offset and size are known (e.g. MAP_IMAGE output).
OUT_POS On output, a 4-element vector specifying the position
actually used to display the image.
NOSCALE If set, the image will not be byte-scaled
(default is to byte-scale the image).
NORESIZE If set, the image will not be resized.
(default is to resize the image to fit the display).
ORDER If set, the image is displayed from the top down
(default is to display the image from the bottom up).
Note that the system variable !ORDER is always ignored.
USEPOS If set, the image will be sized to exactly fit a supplied
POSITION vector, over-riding ASPECT and MARGIN
(default is to honor ASPECT and MARGIN when a POSITION
vector is supplied).
CHANNEL Display channel (Red, Green, or Blue) to be written.
0 => All channels (the default)
1 => Red channel
2 => Green channel
3 => Blue channel
This keyword is only recognized by graphics devices which
support 24-bit decomposed color (WIN, MAC, X). It is ignored
by all other graphics devices. However True color (RGB)
images can be displayed on any device supported by IMDISP.
BACKGROUND If set to a positive integer, the background will be filled
with the color defined by BACKGROUND.
ERASE If set, the screen contents will be erased. Note that if
!P.MULTI is set to display multiple images, the screen is
always erased when the first image is displayed.
AXIS If set, plot axes will be drawn on the image. The default
x and y axis ranges are determined by the size of the image.
When the AXIS keyword is set, IMDISP accepts any keywords
supported by PLOT (e.g. TITLE, COLOR, CHARSIZE etc.).
NEGATIVE If set, a photographic negative of the image is displayed.
The values of BOTTOM and NCOLORS are honored. This keyword
allows True color images scanned from color negatives to be
displayed. It also allows Pseudo color images to be displayed
as negatives without reversing the color table. This keyword
is ignored if the NOSCALE keyword is set.
Outputs
None.
Optional Outputs
None
Common Blocks
None
Side Effects
The image is displayed on the current graphics device.
Restrictions
Requires IDL 5.0 or higher (square bracket array syntax).
Example
;- Load test data
openr, lun, filepath('ctscan.dat', subdir='examples/data'), /get_lun
ctscan = bytarr(256, 256)
readu, lun, ctscan
free_lun, lun
openr, lun, filepath('hurric.dat', subdir='examples/data'), /get_lun
hurric = bytarr(440, 330)
readu, lun, hurric
free_lun, lun
read_jpeg, filepath('rose.jpg', subdir='examples/data'), rose
help, ctscan, hurric, rose
;- Display single images
!p.multi = 0
loadct, 0
imdisp, hurric, /erase
wait, 3.0
imdisp, rose, /interp, /erase
wait, 3.0
;- Display multiple images without color table splitting
;- (works on 24-bit displays only; top 2 images are garbled on 8-bit displays)
!p.multi = [0, 1, 3, 0, 0]
loadct, 0
imdisp, ctscan, margin=0.02
loadct, 13
imdisp, hurric, margin=0.02
imdisp, rose, margin=0.02
wait, 3.0
;- Display multiple images with color table splitting
;- (works on 8-bit or 24-bit displays)
!p.multi = [0, 1, 3, 0, 0]
loadct, 0, ncolors=64, bottom=0
imdisp, ctscan, margin=0.02, ncolors=64, bottom=0
loadct, 13, ncolors=64, bottom=64
imdisp, hurric, margin=0.02, ncolors=64, bottom=64
imdisp, rose, margin=0.02, ncolors=64, bottom=128
wait, 3.0
;- Display an image at a specific position, over-riding aspect and margin
!p.multi = 0
loadct, 0
imdisp, hurric, position=[0.0, 0.0, 1.0, 0.5], /usepos, /erase
wait, 3.0
;- Display an image with axis overlay
!p.multi = 0
loadct, 0
imdisp, rose, /axis, /erase
wait, 3.0
;- Display an image with contour plot overlay
!p.multi = 0
loadct, 0
imdisp, hurric, out_pos=out_pos, /erase
contour, smooth(hurric, 10, /edge), /noerase, position=out_pos, $
xstyle=1, ystyle=1, levels=findgen(5)*40.0, /follow
wait, 3.0
;- Display a small image with correct resizing
!p.multi = 0
loadct, 0
data = (dist(8))[1:7, 1:7]
imdisp, data, /erase
wait, 3.0
imdisp, data, /interp
wait, 3.0
;- Display a true color image without and with interpolation
!p.multi = 0
imdisp, rose, /erase
wait, 3.0
imdisp, rose, /interp
wait, 3.0
;- Display a true color image as a photographic negative
imdisp, rose, /negative, /erase
wait, 3.0
;- Display a true color image on PostScript output
;- (note that color table is handled automatically)
current_device = !d.name
set_plot, 'PS'
device, /color, bits_per_pixel=8, filename='imdisp_true.ps'
imdisp, rose, /axis, title='PostScript True Color Output'
device, /close
set_plot, current_device
;- Display a pseudo color image on PostScript output
current_device = !d.name
set_plot, 'PS'
device, /color, bits_per_pixel=8, filename='imdisp_pseudo.ps'
loadct, 0
imdisp, hurric, /axis, title='PostScript Pseudo Color Output'
device, /close
set_plot, current_device
;- Display an image where only the offset and size are known
;- Read world elevation data
file = filepath('worldelv.dat', subdir='examples/data')
openr, lun, file, /get_lun
data = bytarr(360, 360)
readu, lun, data
free_lun, lun
;- Reorganize array so it spans 180W to 180E
world = data
world[0:179, *] = data[180:*, *]
world[180:*, *] = data[0:179, *]
;- Create remapped image
map_set, /orthographic, /isotropic, /noborder
remap = map_image(world, x0, y0, xsize, ysize, compress=1)
;- Convert offset and size to position vector
pos = fltarr(4)
pos[0] = x0 / float(!d.x_vsize)
pos[1] = y0 / float(!d.y_vsize)
pos[2] = (x0 + xsize) / float(!d.x_vsize)
pos[3] = (y0 + ysize) / float(!d.y_vsize)
;- Display the image
loadct, 0
imdisp, remap, pos=pos, /usepos
map_continents
map_grid Modification History
Liam.Gumley@ssec.wisc.edu
http://cimss.ssec.wisc.edu/~gumley
Copyright (C) 1999, 2000 Liam E. Gumley
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.