Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I was flying cross country last week. We were at about 35000 feet with a complete cloud deck below us. I looked down and saw a complete circular rainbow above the clouds. It was in view about 10 minutes. It went away when the cloud deck began to raise with respect to out flight path. I took several photos thru the window with my small Nikon camera. When I uploaded the photos to my desktop I could barely make out the rainbow. While in flight my eyes had no trouble discerning the shape and colors Red, Orange, Yellow, Green, and Blue, but no Indigo or Violet. I've been trying to use Mathematica to bring out the rainbow in the images, but without much success. I'm asking for ideas on how to enhance the colors and structure of the rainbow. As you will note in the attached photo, there appears to be further structure outside the main rainbow, so it would be interesting to manipulate multiple parameters in the photo. Thanks for your thoughts.enter image description here

share|improve this question
Just to be nitpicking ;-), I believe that's a "glory". –  Peltio Dec 15 '14 at 18:12
FYI: why you didn't see "violet" as it is meant today: youtube.com/watch?v=9udYi7exojk –  Mr.Wizard Dec 15 '14 at 18:15
I wonder why your camera failed to capture any significant color, at least as presented in this image. I don't suppose there is a "RAW" (digital negative) file? Out of curiosity was a polarizing filter of any kind in use? –  Mr.Wizard Dec 15 '14 at 18:22
This is a slightly different phenomenon from a rainbow. It is called a "Brocken Spectre". –  Octopus Dec 15 '14 at 20:46
@Mr.Wizard I guess the eye copes better with the very bright conditions (higher dynamic range) . A polarizing filter per se should not be a problem (perhaps in combination with the windows). I had similar (mediocre) results last time I captured a glory. –  Yves Klett Dec 15 '14 at 21:15

3 Answers 3

Another approach is to try and histogram equalize the image to something similar, but with more pronounced colors. I found this picture at google images

img = Import["http://i.stack.imgur.com/ogkEu.jpg"];

enter image description here

Then the desired picture can take on (something of) the coloration of the new image using

HistogramTransform[img, img2]

enter image description here

share|improve this answer
I wonder why there is so much white in there –  belisarius Dec 15 '14 at 19:01
@belisarius -- it's hard to know for sure, but I would guess it is a result of the transformation working on a channel-by-channel basis. –  bill s Dec 15 '14 at 19:09
curious,isn't it? {h, s, b} = ColorSeparate[img, "HSB"]; {h2, s2, b2} = ColorSeparate[img2, "HSB"]; ColorCombine[{HistogramTransform[h, h2], HistogramTransform@s, HistogramTransform@b}, "HSB"] –  belisarius Dec 15 '14 at 19:23
@belisarius -- The weird colors actually make some sense: the hue channel is getting all scrambled around by the equalization, essentially returning random colors. For comparison, try HistogramTransform[ColorConvert[img, "LAB"], ColorConvert[img2, "LAB"]] –  bill s Dec 15 '14 at 19:37
Is this answer really enhancing the colours and structure that exist in the original image, or is it simply imposing the colours and structure of a different image on it? –  Rahul Dec 15 '14 at 21:45

Plain old ImageAdjust will improve it quite a lot, though you have to chop off the bright orange text to stop the algorithm being fooled:

ImageAdjust[img ~ImageTake~ 2100]

enter image description here

You could now bring out the colours a bit more with a boost to the contrast of the saturation channel:

 ColorCombine[MapAt[ImageAdjust[#, {0, 2, 1}] &, ColorSeparate[%, "HSB"], 2], "HSB"]

enter image description here

share|improve this answer

There appears to be insufficient data in the provided image. Boosting saturation by a factor of ten:

img = Import["http://i.stack.imgur.com/ogkEu.jpg"];

hsb = ColorConvert[img, "HSB"];

ImageApply[# {1, 10, 1} &, hsb]

enter image description here

share|improve this answer
@MichaelE2 Oops! I used a drag-and-drop in the code I actually ran and that produced an alpha channel, then I just added the Import when I pasted it here. It was hubris to think I knew how the code would evaluate. –  Mr.Wizard Dec 16 '14 at 19:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.