1

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?

  • Why not use `TV` instead of `POLYPILL`? `TV` (or `TVSCL` or one of the third party image display routines) is intended for displaying images. – mgalloy Apr 24 '15 at 04:13
  • Thanks, I used TVSCL originally, but really wanted a way to easily control the size of the 'pixels', and also to be able to combine the plot with other time series plots in multi-panel windows. – user2137944 Apr 24 '15 at 10:53

2 Answers2

1

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.

mgalloy
  • 2,356
  • 1
  • 12
  • 10
1

You could also use new graphics if you have IDL 8.4+

no_images = 100
ut = FINDGEN(100)/100*24
img = bytscl(randomu(seed,no_images,40))
y = FINDGEN(40)
p = PLOT(ut, y, XSTYLE=1, YSTYLE=1, XRANGE=[0,24], YRANGE=[0,40], $
  /NODATA, TITLE='My Data',XTITLE='X',YTITLE='Y')
i = IMAGE(img, ut, y, /OVERPLOT, RGB_TABLE=74, ASPECT_RATIO=0.5)

You can adjust the ASPECT_RATIO to make your image appear more or less square. And it's easy to change the RGB_TABLE to whatever one you'd like.

Chris Torrence
  • 452
  • 3
  • 11