Ask Your Question
3

Single Image Depth Map / Sharpness Map

asked 2012-10-06 04:11:02 -0600

Royi gravatar image

Hello,

Is there a way using OpenCV to create a gray scale image of the Depth Map / Sharpness Level of an image?
I don't need the "Depth Map" to be accurate, just to set a different shade of gray to a different distances.
Equivalently, set a different gray level according to the sharpness of the area (Since Distance, Focus Distance and Depth of Field set the sharpness).

Any idea?

Thanks.

edit retag flag offensive close merge delete

Comments

Where would the distance information come from, if you have a single image as input?

HugoRune gravatar imageHugoRune ( 2012-10-06 04:33:06 -0600 )edit
1

I don't need estimation of the distance (Namely, the distance in [Meter]), only that different distances are in different shades of gray. This could be done by estimating the "Sharpness". Since the focus is set to a certain distance anything in a different distance would have a different "Sharpness" (Blur) level according the Depth of Field.

Royi gravatar imageRoyi ( 2012-10-06 04:45:49 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-10-07 04:13:27 -0600

HugoRune gravatar image

One thing you could try is running a laplacian filter across the image, regions with higher peaks will be sharper.

However this will not work in regions with little structure, or if your foreground is sharper but less detailed than the background.

  • cv::Laplace on the image to detect sharp edges
  • cv::ConvertScaleAbs since laplacian peaks will be negative as well as positive
  • cv::Dilate to increase the region around edges that is marked as sharp
  • cv::GaussianBlur to further increase the region around edges that is recognised as sharp

the resulting image should be a very rough map of sharpness

This is just a very bad approximation though, I'd love to see a better way to measure local sharpness

also see this Stackoverflow question (deals with global blur only)

edit flag offensive delete link more

Comments

Thank for the idea. I will give it a try. Have you seen any other methods to create an estimated "Sharpness Map"? Thanks.

Royi gravatar imageRoyi ( 2012-10-15 02:10:03 -0600 )edit

Question Tools

4 followers

Stats

Asked: 2012-10-06 04:11:02 -0600

Seen: 7,469 times

Last updated: Oct 07 '12