# How can I create a colour image using raw black and white data? (FITS data cube)

I have a data cube containing pictures of a galaxy across a thousand wavelengths. I want to take the data for the image slides in the red and blue parts of the spectrum, and have them represented in the appropriate colours. If I could then superimpose the images somehow to show the red and blue regions of the galaxy together that would be fantastic.

Currently I have been working with the raw data for each slide and the pixel magnitudes. To plot the galaxy at any given wavelength I've just being using a list density plot. I don't know how to map the range of images with a gradual colour change or how to combine them?

-
Can be an interesting question if you show us what you have done so far. I mean your code and data and the way you are forming those list density plots! –  PlatoManiac Nov 26 '13 at 17:07
yeah, perhaps two pictures and the code is enough –  belisarius Nov 26 '13 at 17:14
You need to use Image, ColorCombine, and related image processing functions. Don't use ListDensityPlot for this purpose. If you post the FITS file (Dropbox, ge.tt, your own hosting, etc.), and a description of the data within, we can show you how to do it. But we need some example data to work with. –  Szabolcs Nov 26 '13 at 17:22
I would use transparency on dim-lit pixels and stack those images as textures on whatever foliation you have. –  Hector Nov 26 '13 at 19:18
@Szabolcs & Hector I think the main problem will be with importing the data. MMA knows simple FITS but I've failed to import multidimensional images and had to use dedicated software because of lack of time to deal with it. I will post sample data as soon as I learn how to use dropbox :P –  Kuba Nov 26 '13 at 19:36

Why don't you use the CIE color matching functions to turn the sampled spectrum contained in each pixel into a color as you would perceive it yourself?

Lots of color matching functions here. Let's import the old but much used 1931 dataset:

cie = Import["http://cvrl.ioo.ucl.ac.uk/database/data/cmfs/ciexyz31_1.csv"];


They look like this:

{cie[[All, 1]], cie[[All, #]]}\[Transpose] & /@ {2, 3, 4} // ListPlot


These matching functions can be used to turn spectral data into (X, Y, Z) color coordinates as follows:

$X = \int x (\lambda) s (\lambda) \, d\lambda$

$Y = \int y (\lambda) s (\lambda) \, d\lambda$

$Z = \int z (\lambda) s (\lambda) \, d\lambda$

with $x (\lambda)$, $y (\lambda)$, $z (\lambda)$ the CIE color matching functions for X, Y and Z, respectively, and $s$ your spectrum as a function of wavelength $\lambda$ (the pixel value in each of the 1000 wavelength pics).

The X, Y, Z values you obtain in this way can be turned into RGB values using ColorConvert. Some scaling may be necessary.

ColorConvert[{xval,yval,zval}, "XYZ" -> "RGB"]

-