2016-01-13 128 views
0

我想实现这个USM锐化算法,我发现在hereOpenCV的USM锐化Java实现

编辑:这是算法。

Mat blurred; double sigma = 1, threshold = 5, amount = 1; 
GaussianBlur(img, blurred, Size(), sigma, sigma); 
Mat lowContrastMask = abs(img - blurred) < threshold; 
Mat sharpened = img*(1+amount) + blurred*(-amount); 
img.copyTo(sharpened, lowContrastMask); 

我坚持在这里:

// Mat lowContrastMask = abs(img - blurred) < threshold; 

    Mat lowContrastMask = new Mat(); 
    Core.absdiff(source, destination, lowContrastMask); 

我不知道如何实现 “<门槛” 的一部分。我感谢任何帮助。

+0

您的链接不指向任何算法,只是OpenCV的文档 – Miki

+0

我更新的问题 – bodoroman

回答

0

您可以使用threshold

Imgproc.threshold(lowContrastMask, lowContrastMask, 0, thresh, Imgproc.THRESH_BINARY_INV) 
+0

它不给任何错误,但结果并不那么好。我想我的算法有很多错误。 – bodoroman