Picture/
imdisp.pro
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, and Z 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.
imdisp
Picture
imdisp, IMAGE, RANGE=vector, BOTTOM=BOTTOM, NCOLORS=NCOLORS, MARGIN=MARGIN, INTERP=INTERP, DITHER=DITHER, ASPECT=ASPECT, POSITION=POSITION, OUT_POS=OUT_POS, NOSCALE=NOSCALE, NORESIZE=NORESIZE, ORDER=ORDER, USEPOS=USEPOS, CHANNEL=CHANNEL, BACKGROUND=BACKGROUND, ERASE=ERASE, AXIS=AXIS, NEGATIVE=NEGATIVE, _EXTRA=_EXTRA
Parameters
IMAGE
in
required
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.
Keywords
RANGE
type: vector
default: min and max array values
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
This keyword is ignored for True Color images,
or if the NOSCALE keyword is set.
BOTTOM
default: 0
Bottom value in the color table to be used
for the byte-scaled image.
This keyword is ignored if the NOSCALE keyword is set.
NCOLORS
default: !D.TABLE_SIZE - BOTTOM
Number of colors in the color table to be used
for the byte-scaled image
This keyword is ignored if the NOSCALE keyword is set.
MARGIN
default: 0.1 or 0.025 if !P.MULTI is set to display multiple images
A scalar value specifying the margin to be maintained
around the image in normal coordinates
INTERP
default: nearest neighbor sampling
If set, the resized image will be interpolated using
bilinear interpolation
DITHER
default: no dithering
If set, true color images will be dithered when displayed
on an 8-bit graphics device
ASPECT
default: maintain native aspect ratio
A scalar value specifying the aspect ratio (height/width)
for the displayed image
POSITION
default: [0.0,0.0,1.0,1.0]
On input, a 4-element vector specifying the position
of the displayed image in the form [X0,Y0,X1,Y1] in
in normal coordinates
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
default: to byte-scale the image
If set, the image will not be byte-scaled.
NORESIZE
default: To resize the image to fit the display
If set, the image will not be resized.
ORDER
default: To display the image from the bottom up
If set, the image is displayed from the top down
Note that the system variable !ORDER is always ignored.
USEPOS
default: To honor ASPECT and MARGIN when POSITION vector is supplied
If set, the image will be sized to exactly fit a supplied
POSITION vector, over-riding ASPECT and MARGIN.
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.
_EXTRA
Examples
;- 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
Version history
Version
$Id: imdisp.pro 163 2006-08-29 12:59:46Z navarro $
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.
Known issues
Restrictions
The image is displayed on the current graphics device.
Requires IDL 5.0 or higher (square bracket array syntax).
Produced by IDLdoc 2.0 on Wed Sep 13 16:32:22 2006.