; --------- aph 31-dec-01) ----------------
; routine to place tiff images into a 3d array for slicer

file=pickfile2()  ; get tiff file name

a=read_tiff(file, R,G,B)	; read tiff - these are a 24-bit image interleaved representation

tmp = color_quan(a,1,R,G,B, colors = 216)	; convert to 1-plane and a color scheme - NB 216 works !

tmp = reverse(tmp,2)	; so it has same orientation as in aXis2000

tvlct, r, g, b		; load the color table

tv, tmp		; display the image

; ----------- PROBLEM !! - the RGB structure differs for each of these !!
; ----------- SOLUTION - determine a common RGB palette for all files
; Or -------- write all red, all gree, all blue from the separate gif files.
; - but the gif files are all byte scaled when written - really need to go back to *.axb's and
; generate from them !!
; ----- FANNING tip - use 24-bit and put R's in the lower 8-bit, G's in middle and B's in top

' conversion method
image2d = name of byte image to be converted'
 scaled = BytScl(image2D, Top=!D.Table_Size-1)

; Create a 24-bit image of the proper size.

  s = Size(scaled, /Dimensions)
  image24 = BytArr(3, s[0], s[1])

  ; Get the color table vectors.

   TVLCT, r, g, b, /Get

      ; Prepare the image color separations.

  image24[0, *, *] = r[scaled]
  image24[1, *, *] = g[scaled]
  image24[2, *, *] = b[scaled]

Now you are all set to create a 24-bit TIFF or JPEG file. For example, to create a JPEG file, you would write this:
pngfile = pickfile2()
Write_png, png_file, image24

; ----- check can read and display ----
