我正在写一个高斯滤波器,我的目标是尽可能地匹配photoshop中的高斯模糊滤波器.这是我的第一次图像处理工作.我遇到的一些问题是......
使用我的滤镜进一步模糊图像使其变暗,而photoshop似乎使其变亮.
我使用的偏差值(我的代码中的"sigma")是r/3,这导致高斯曲线在矩阵内接近约0.0001 ...有更好的方法来确定这个值吗?
Photoshop(或大多数人)如何处理此类模糊的图像边框?
int matrixDimension = (radius*2)+1;
float sigma = radius/3;
float twoSigmaSquared = 2*pow(sigma, 2);
float oneOverSquareRootOfTwoPiSigmaSquared = 1/(sqrt(M_PI*twoSigmaSquared));
float kernel[matrixDimension];
int index = 0;
for (int offset = -radius; offset <= radius; offset++) {
float xSquared = pow(offset, 2);
float exponent = -(xSquared/twoSigmaSquared);
float eToThePower = pow(M_E, exponent);
float multFactor = oneOverSquareRootOfTwoPiSigmaSquared*eToThePower;
kernel[index] = multFactor;
index++;
}
//Normalize the kernel such that all its values will add to 1
float sum = 0;
for (int i …Run Code Online (Sandbox Code Playgroud)