linear blur

This commit is contained in:
Damian Kowalski 2024-04-07 14:29:53 +02:00
parent f9af87a5d5
commit 3176a1e15e

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