Search code examples
imageplotidl-programming-language

Plotting in IDL using POLYFILL


My supervisor has suggested the following code for extracting vertical slices from a set of 40 x 40 images and plotting them as a time series (24hrs), with images stored in an array 'images = FLTARR(no_images, 40,40)', and corresponding times in array UT=FLTARR(no_images):

PLOT, [0],[0], /NODATA, XRANGE=[0,24], XSTYLE, YRANGE=[-40,40], /YSTYLE

FOR i=0, no_images-1 DO BEGIN
FOR j=0, 39 DO BEGIN
POLYFILL, UT(i)+[0,0,1,1]*2/60.0, (j+[0,1,1,0])*2-40, COL=[work out what colour you want the pixel to be in terms of the value in images(i,20,j) ]
ENDFOR
ENDFOR

The images were taken at 2 minute intervals.

I understand what is being done here - essentially drawing small rectangles to represent the pixels in the images. My question is what should the COL argument be? Can someone give me an example? At the minute to test the code i've just put a fixed value (e.g. 255), which obviously just gives a block of the same color. How can i get different colours corresponding to the pixel values?


Solution

  • Just use:

    max_value = max(ut[*, 20, *])
    color=images[i, 20, j] / float(max_value) * 255
    

    Make sure you are in indexed color, i.e., you have done:

    device, decomposed=0
    

    and used used LOADCT or TVLCT to load the color table you want to use.