From: finkh on
The Lunar Orbiter Laser Altimeter has a website http://lro.gsfc.nasa.gov/lola/science.html
where jpegs are posted of regions of the moon. I would like to
convert the color information to height values. A scale is posted
with the images that looks a lot like Rainbow, a ColorFunction. I
have Inserted the jpeg of Copernicus into a mathematica notebook. It
has 5 dimensions, which look like rows, columns, and RGB, where RGB
runs from 0 to 255. How can I convert an RGB Rainbow triple to a
single number?


From: Patrick Scheibe on
Hi,

the scale looks like they used the color-angle of the HUE-colorspace.
So lets check: Taking the colorscale region of one of the image and
calculating (an slightly adapted) HUE-angle gives:

img = Import[
"http://lro.gsfc.nasa.gov/lola/images/weekly/20100318.jpg"]
scaleimg = ImageTake[img, {-50, -30}, {5, 305}]
scale = ImageData[scaleimg, "Real"];
h2[{r_, g_, b_}] :=
Block[{\[Alpha] = 1/2 (2 r - g - b), \[Beta] = Sqrt[3]/2 (g - b)},
If[\[Alpha] == \[Beta] == 0., \[Beta] += 10^-6.];
Mod[ArcTan[\[Alpha], \[Beta]] + 0.1, 2 Pi]
];
DistributeDefinitions[h2]
ListPlot[h2 /@ (Mean /@ Transpose[scale])]

Looks promising. Not really linear but since it is a low quality jpg
image the negative HUE-angle should be ok as height.
So lets take the part of the image with the map and using a gaussian
filter to smooth the data a bit:

img2 = ImageTake[GaussianFilter[img, 5], {1, -90}];
heights = ParallelMap[-h2[#] &, ImageData[img2, "Real"], {2}];
ListPlot3D[heights]

Cheers
Patrick

On Fri, 2010-05-14 at 05:36 -0400, finkh wrote:
> The Lunar Orbiter Laser Altimeter has a website http://lro.gsfc.nasa.gov/lola/science.html
> where jpegs are posted of regions of the moon. I would like to
> convert the color information to height values. A scale is posted
> with the images that looks a lot like Rainbow, a ColorFunction. I
> have Inserted the jpeg of Copernicus into a mathematica notebook. It
> has 5 dimensions, which look like rows, columns, and RGB, where RGB
> runs from 0 to 255. How can I convert an RGB Rainbow triple to a
> single number?
>
>