Images: {Gumley 7.1-7.4, 7.6} pseudo color => one 2D array (x,y) of values on the screen, each corresponding to a pixel and each with 256 RGB choices (i.e., each pixel is assigned a value that corresponds to an entry in the color table). or true color => three 2D arrays on the screen, one for red, one for green and one for blue (i.e., each pixel is assigned three values, R,G,B, each of which has 256 possible choices). We will use pseudo color (decomposed=0). A color image is a 2D array of bytes, with each element corresponding to an index between 0 and 255 in a color table and representing the color of one pixel in the displayed image. For this set of notes you need to first get a file called datafile, which is an unformatted file containing a floating point array of size (100,100). It is posted on the course web page next to these notes. IDL> WINDOW,1 IDL> f=FLTARR(100,100) IDL> OPENR,1,'datafile',/SWAP_IF_LITTLE_ENDIAN note, the data was written on a "big endien" computer and therefore the /SWAP_IF_LITTLE_ENDIAN keyword is only needed if you are on a "little endian" computer, like a Mac. IDL> READU,1,f IDL> CLOSE,1 IDL> DEVICE,DECOMPOSED=0 IDL> LOADCT,33 IDL> SHADE_SURF,f,SHADES=BYTSCL(f),IMAGE=imagearray note, the IMAGE keyword causes the image to be saved in the 2D array imagearray, one byte per element IDL> HELP,imagearray IDL> WINDOW,2 IDL> TV,imagearray IDL> LOADCT,5 IDL> ERASE IDL> TV,imagearray IDL> PRINT,MIN(imagearray),MAX(imagearray) IDL> PRINT,MIN(f),MAX(f) IDL> WINDOW,3 IDL> TVSCL,f ; same as TV,BYTSCL(f) note, this scales the values of f to be between 0 and 255 and then displays the 2D image IDL> OPENW,1,'image.dat' IDL> WRITEU,1,imagearray IDL> CLOSE,1 IDL> .RESET IDL> WINDOW,1,XSIZE=558,YSIZE=485 ; or maybe XSIZE=430,YSIZE=357 IDL> DEVICE,DECOMPOSED=0 IDL> LOADCT,33 IDL> OPENR,1,'image.dat' IDL> image2=BYTARR(558,485) ; or maybe BYTARR(430,357) IDL> READU,1,image2 IDL> TV,image2 IDL> TV,image2,/ORDER note, /ORDER plots from top to bottom (instead of bottom to top) IDL> TV,image2 IDL> TV,image2 < 200 note, this displays the image but converts any byte index greater than 200 to be 200 IDL> TVSCL,image2 < 200 note, this does as above but rescales the data to span from 0 to 255, i.e., to use the entire color table IDL> TV,image2 > 40 IDL> TVSCL,image2 > 40 IDL> image_small=CONGRID(image2,250,200) IDL> WINDOW,2,XSIZE=250,YSIZE=200 IDL> TV,image_small IDL> image_large=CONGRID(image2,800,600) IDL> WINDOW,3,XSIZE=800,YSIZE=600 IDL> TV,image_large IDL> WDELETE IDL> WDELETE IDL> WDELETE Making a postscript file of an image. IDL> PRINT,!D.NAME note, X stands for X-terminal mode, i.e., a window on your the screen IDL> SET_PLOT,'PS' IDL> PRINT,!D.NAME note, PS stands for the postscript mode. note, WINDOW does not work when in PS mode. note, you can't do "DEVICE,DECOMPOSED=0" when in PS mode, so you need to do this before you enter PS mode. IDL> DEVICE,/COLOR,BITS_PER_PIXEL=8,FILENAME='image.ps', $ IDL> XSIZE=4.,YSIZE=3.,/INCHES note, the default is 4 bits per pixel and the default units for XSIZE and YSIZE are cm. recall: 1 byte = 8 bits => 2^8 = 256 color choices per pixel. IDL> LOADCT,33 IDL> TV,image2 note, the display of image2 is sent to the postscript file (image.ps) instead of the screen IDL> DEVICE,/CLOSE_FILE note, this closes the postscript file and the next procedure opens a new ps file. IDL> DEVICE,/COLOR,BITS_PER_PIXEL=8,FILENAME='dist_plot.ps', $ IDL> XSIZE=7.,YSIZE=4.,/INCHES IDL> d=DIST(100,100) IDL> SHADE_SURF,d,SHADES=BYTSCL(d) IDL> SURFACE,d IDL> DEVICE,/CLOSE_FILE IDL> SET_PLOT,'X' note, this restores the device to its original setting (X-terminal) and should also be done in a procedure file because otherwise the IDL device remains PS even after the procedure ends. You can send other types of graphics to a postscript file, by using, for example, CONTOUR, SURFACE, PLOT, ... while SET_PLOT is still set to 'PS'. Now you can view image.ps and dist_plot.ps (from unix, outside IDL) by using a viewer, like ghostview if you are on a Sun workstation or by just clicking on the icon if on a Mac. Check the online documentation for TV to see how to place several images in different locations on one page. Check the keyword /encapsul that can be used with device to make encapsulated postscript files, which are sometimes better for incorporating figures into text documents. Note, images that are displayed with a black background on a screen sometimes look better with a white background when displayed with postscript. Here's an easy way to do this for a byte array, f, when the grey color table (LOADCT,0) is being used. f[WHERE(f EQ 0B)]=255B