Compare commits
3 Commits
04c2054e8e
...
3176a1e15e
Author | SHA1 | Date | |
---|---|---|---|
|
3176a1e15e | ||
|
f9af87a5d5 | ||
|
7ae6e9433c |
@ -25,15 +25,16 @@ math::matrix<float> BlurGaussian::getMask(int size, Mode)
|
||||
{
|
||||
math::matrix<float> mask(size, size);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
for (int i = 0; i < size; i++)
|
||||
for (int j = 0; j < size; j++)
|
||||
mask(i, j) = getGauss(i - radius, j - radius, sigma);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
float BlurGaussian::getGauss(int x, int y, float sigma)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
|
||||
return 0;
|
||||
float expValue = exp(-(pow(x, 2) + pow(y, 2)) / (2 * pow(sigma, 2)));
|
||||
return (1 / (2 * M_PI * pow(sigma, 2))) * expValue;
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,32 @@ BlurLinear::BlurLinear(PNM* img, ImageViewer* iv) :
|
||||
{
|
||||
}
|
||||
|
||||
PNM* BlurLinear::transform()
|
||||
{
|
||||
PNM* BlurLinear::transform() {
|
||||
int maskSize = getParameter("size").toInt();
|
||||
QList<QVariant> tmpMask = getParameter("mask").toList();
|
||||
bool normalize = getParameter("normalize").toBool();
|
||||
|
||||
math::matrix<float> mask(maskSize, maskSize);
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Not implemented yet!";
|
||||
int currentMask = 0;
|
||||
for (int x = 0; x < maskSize; x++) {
|
||||
for (int y = 0; y < maskSize; y++) {
|
||||
mask(x, y) = tmpMask.at(currentMask).toDouble();
|
||||
currentMask++;
|
||||
}
|
||||
}
|
||||
|
||||
if (normalize) {
|
||||
float summed = sum(mask);
|
||||
if (summed == 0) {
|
||||
summed = 1.0;
|
||||
}
|
||||
for (int x = 0; x < maskSize; x++) {
|
||||
for (int y = 0; y < maskSize; y++) {
|
||||
mask(x, y) /= summed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return convolute(mask, RepeatEdge);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user