1
0
lpo-image-processing/04/do_sprawdzenia/cpp/blur_linear.cpp

41 lines
919 B
C++
Raw Normal View History

2021-03-20 17:56:06 +01:00
#include "blur_linear.h"
BlurLinear::BlurLinear(PNM* img) :
Convolution(img)
{
}
BlurLinear::BlurLinear(PNM* img, ImageViewer* iv) :
Convolution(img, iv)
{
}
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);
int maskValCount = 0;
for (int i=0; i < maskSize; i++)
{
for (int j=0; j < maskSize; j++)
{
if (normalize)
{
mask[i][j] = tmpMask.at(maskValCount).toDouble() / Convolution::sum(mask);
maskValCount++;
}
else
{
mask[i][j] = tmpMask.at(maskValCount).toDouble();
maskValCount++;
}
}
}
return convolute(mask, RepeatEdge);
}