How can I sharpen an image in OpenCV?

One general procedure is laid out in the Wikipedia article on unsharp masking:

You use a Gaussian smoothing filter and subtract the smoothed version from the original image (in a weighted way so the values of a constant area remain constant).

To get a sharpened version of frame into image: (both cv::Mat)

cv::GaussianBlur(frame, image, cv::Size(0, 0), 3);
cv::addWeighted(frame, 1.5, image, -0.5, 0, image);

The parameters there are something you need to adjust for yourself.

There’s also Laplacian sharpening, you should find something on that when you google.

Leave a Comment