Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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)