Implement updateDenoisedImage(), call TVdenoising
This commit is contained in:
25
src/main.cpp
25
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()
|
||||
|
Reference in New Issue
Block a user