From bee9d1f89ca89e85a06b6ec613d0d0cf3f55e955 Mon Sep 17 00:00:00 2001 From: Patrycjusz Mania Date: Wed, 16 Jun 2021 20:54:14 +0200 Subject: [PATCH] zadanie - 10 (odszumianie) --- src/core/transformations/noise_bilateral.cpp | 43 ++++++++++++++++---- src/core/transformations/noise_median.cpp | 28 +++++++++++-- 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/core/transformations/noise_bilateral.cpp b/src/core/transformations/noise_bilateral.cpp index cc6579f..7288a9b 100644 --- a/src/core/transformations/noise_bilateral.cpp +++ b/src/core/transformations/noise_bilateral.cpp @@ -17,32 +17,59 @@ PNM* NoiseBilateral::transform() PNM* newImage = new PNM(width, height, image->format()); - sigma_d = getParameter("sigma_d").toInt(); + sigma_d = getParameter("sigma_d").toInt() * 1.8; sigma_r = getParameter("sigma_r").toInt(); radius = sigma_d; - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + for (int x=0;xsetPixel(x, y, QColor(r,g,b).rgb()); + } + } return newImage; } int NoiseBilateral::calcVal(int x, int y, Channel channel) { - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + math::matrix window = getWindow(x, y, radius, channel, RepeatEdge); - return 0; + float sumCounter = 0; + float sumDenominator = 0; + int pixel = image->pixel(x,y); + switch (channel) { + case RChannel: pixel = qRed(pixel); + case GChannel: pixel = qGreen(pixel); + case BChannel: pixel = qBlue(pixel); + } + for (int i=0;iformat()); - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + for (int x=0;xsetPixel(x, y, QColor(r,g,b).rgb()); + } + } return newImage; } int NoiseMedian::getMedian(int x, int y, Channel channel) { - int radius = getParameter("radius").toInt(); + int radius = getParameter("radius").toInt() * 2 + 1; + math::matrix window = getWindow(x, y, radius, channel, RepeatEdge); + int items = radius * radius; + int tmp[items]; - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + int i=0; + for (int x=0;x