From 1028f64ba4efd4e20b2e046df74def98c0617e7d Mon Sep 17 00:00:00 2001 From: BohdanBakhlul Date: Sat, 19 Jun 2021 06:28:31 +0200 Subject: [PATCH] zadanie_10 --- src/core/transformations/noise_bilateral.cpp | 48 ++++++++++++++++---- src/core/transformations/noise_median.cpp | 34 ++++++++++++-- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/core/transformations/noise_bilateral.cpp b/src/core/transformations/noise_bilateral.cpp index cc6579f..755f089 100644 --- a/src/core/transformations/noise_bilateral.cpp +++ b/src/core/transformations/noise_bilateral.cpp @@ -19,30 +19,58 @@ PNM* NoiseBilateral::transform() sigma_d = getParameter("sigma_d").toInt(); sigma_r = getParameter("sigma_r").toInt(); - radius = sigma_d; + radius = sigma_d * 2; - 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; + int pixel = image->pixel(x,y); + + switch (channel) { + case RChannel: pixel = qRed(pixel); + case GChannel: pixel = qGreen(pixel); + case BChannel: pixel = qBlue(pixel); + } + + float sum1 = 0; + float sum2 = 0; + + 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; } @@ -25,8 +32,29 @@ PNM* NoiseMedian::transform() int NoiseMedian::getMedian(int x, int y, Channel channel) { int radius = getParameter("radius").toInt(); + radius = radius * 2 + 1; - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + math::matrix window = getWindow(x, y, radius, channel, RepeatEdge); + int table_size = radius * radius; + int table[table_size]; - return 0; + int table_index = 0; + + for (int x=0;x