MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Converting colors to height values

  • To: mathgroup at
  • Subject: [mg109748] Re: Converting colors to height values
  • From: Patrick Scheibe <pscheibe at>
  • Date: Fri, 14 May 2010 08:28:55 -0400 (EDT)


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[
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]
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}];


On Fri, 2010-05-14 at 05:36 -0400, finkh wrote:
> The Lunar Orbiter Laser Altimeter has a website
> 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?

  • Prev by Date: Re: How to write reports and books in Mathematica
  • Next by Date: Re: NIntegrate Confusion
  • Previous by thread: Converting colors to height values
  • Next by thread: Re: innerApply[{f, g}, {{a, b}, {c, d}}] = {f[a, b],