Alex Rivera | Logout

In a digital photo, how can I detect if a mountain is obscured by clouds?

Asked 2010-03-27T06:13:39.697
27

The problem

I have a collection of digital photos of a mountain in Japan. However the mountain is often obscured by clouds or fog.

What techniques can I use to detect that the mountain is visible in the image? I am currently using Perl with the Imager module, but open to alternatives.

All the images are taken from the exact same position - these are some samples.

Sample Images http://www.freeimagehosting.net/uploads/7304a6e191.jpg

My naïve solution

I started by taking several horizontal pixel samples of the mountain cone and comparing the brightness values to other samples from the sky. This worked well for differentiating good image 1 and bad image 2.

However in the autumn it snowed and the mountain became brighter than the sky, like image 3, and my simple brightness test started to fail.

Image 4 is an example of an edge case. I would classify this as a good image since some of the mountain is clearly visible.

UPDATE 1

Thank you for the suggestions - I am happy you all vastly over-estimated my competence.

Based on the answers, I have started trying the ImageMagick edge-detect transform, which gives me a much simpler image to analyze.

convert sample.jpg -edge 1 edge.jpg

Edge detected samples http://www.freeimagehosting.net/uploads/caa9018d84.jpg

I assume I should use some kind of masking to get rid of the trees and most of the clouds.

Once I have the masked image, what is the best way to compa

Edit
Report

1 Answer

5

A few specific recommendations, building upon what you've got already:

  1. Take your best image (something like image 1), run it through edge detection, open the result in any graphic editor (MS Paint will do) and clean everything except the mountain top boundary (the "chinese hat" line). This is you convolution kernel. You can crop it (not resize!) from above and below to save some time in the next step.
  2. Use the Convolve function from PerlMagick (you seem already comfortable with Perl and ImageMagick) to convolve the kernel with a few images. On the resulting image you should see a sharp spike corresponding to the "correct" position of the kernel (coinciding with the mountain in the image).
  3. The relative (to the level of surrounding noise) height of this spike will be larger when the mountain is better visible. By taking several representative images you might be able to determine a threshold that will separate good images from the bad ones.
  4. Whatever you do, there will be false positives and false negatives. Be prepared.
answered 2010-03-27T22:51:21.843

Your Answer