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()