Compare commits

...

3 Commits

Author SHA1 Message Date
Damian Kowalski
3176a1e15e linear blur 2024-04-07 14:29:53 +02:00
Damian Kowalski
f9af87a5d5 getmask implemented in gauss 2024-04-07 14:17:12 +02:00
Damian Kowalski
7ae6e9433c getgauss implemented 2024-04-07 14:15:24 +02:00
2 changed files with 25 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);
}