From 7c2cd2fff0339e753cadbea64c58f1887f2e5c3b Mon Sep 17 00:00:00 2001 From: Vargha Csongor Date: Sun, 25 Jun 2023 16:07:35 +0200 Subject: [PATCH] Implement updateDenoisedImage(), call TVdenoising --- src/main.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b94459e..f5076ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,7 +38,30 @@ QSlider* iterationsSlider; void updateDenoisedImage() { - + std::string inputImagePath = inputImagePathEdit->text().toStdString(); + std::string outputImagePath = outputImagePathEdit->text().toStdString(); + float lambda = lambdaSlider->value() / 100.0; + int iterations = iterationsSlider->value(); + + // Read the input image + cv::Mat image = cv::imread(inputImagePath, cv::IMREAD_GRAYSCALE); + + // Check if the image was successfully loaded + if (image.empty()) + { + QMessageBox::critical(nullptr, "Error", "Failed to read the input image."); + return; + } + + // Perform TV denoising + TVDenoising(image, lambda, iterations); + + // Display the denoised image + QImage resultImage(image.data, image.cols, image.rows, QImage::Format_Grayscale8); + resultImageLabel->setPixmap(QPixmap::fromImage(resultImage)); + + // Save the denoised image + cv::imwrite(outputImagePath, image); } void openInputImage()