USM算法是PS常用的算法,原理可以在网上看看,这样主要是实现的代码。
opencv实现USM算法的代码是:
void ImageSharp(Mat &src, Mat &dst, int nAmount = 200)
{
double sigma = 3;
int threshold = 1;
float amount = nAmount / 100.0f;
Mat imgBlurred;
GaussianBlur(src, imgBlurred, Size(), sigma, sigma);
Mat lowContrastMask = abs(src - imgBlurred)<threshold;
imshow("ddd", lowContrastMask);
dst = src*(1 + amount) + imgBlurred*(-amount);
src.copyTo(dst, lowContrastMask);
}
改写成Emgucv的实现代码:
private void GetMat(Image<Gray, byte> srcimg, Image<Gray, byte> imgBlurred, ref Mat dst,