linear blur
This commit is contained in:
parent
f9af87a5d5
commit
3176a1e15e
@ -10,15 +10,32 @@ BlurLinear::BlurLinear(PNM* img, ImageViewer* iv) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PNM* BlurLinear::transform()
|
PNM* BlurLinear::transform() {
|
||||||
{
|
|
||||||
int maskSize = getParameter("size").toInt();
|
int maskSize = getParameter("size").toInt();
|
||||||
QList<QVariant> tmpMask = getParameter("mask").toList();
|
QList<QVariant> tmpMask = getParameter("mask").toList();
|
||||||
bool normalize = getParameter("normalize").toBool();
|
bool normalize = getParameter("normalize").toBool();
|
||||||
|
|
||||||
math::matrix<float> mask(maskSize, maskSize);
|
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);
|
return convolute(mask, RepeatEdge);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user