From c8e2f9b694e4210ca25b3b1280378d8156c5ffa6 Mon Sep 17 00:00:00 2001 From: Vargha Csongor Date: Sun, 25 Jun 2023 14:09:12 +0200 Subject: [PATCH] Init main.cpp and tv_denoising.hpp --- include/tv_denoising.hpp | 12 +++++++++++ src/main.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 include/tv_denoising.hpp create mode 100644 src/main.cpp diff --git a/include/tv_denoising.hpp b/include/tv_denoising.hpp new file mode 100644 index 0000000..76fa948 --- /dev/null +++ b/include/tv_denoising.hpp @@ -0,0 +1,12 @@ +/* +Author: Vargha Csongor Csaba +Created: 2023-06-25 10:23:33 +*/ +#ifndef TV_DENOISING_H +#define TV_DENOISING_H + +#include + +extern "C" void TVDenoising(cv::Mat& image, float lambda, int maxIterations); + +#endif // TV_DENOISING_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..e1f4901 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,44 @@ +/* +Author: Vargha Csongor Csaba +Created: 2023-06-25 10:10:13 + +Description: + This file contains the main function for the TV image denoising cli tool. + It reads an image file, denoises it using the TV denoising algorithm, + and saves the denoised image to a file. + You can run it with the following command: + ./TV_Denoising_CUDA + where is the path to the image file you want to denoise. +*/ +#include +#include +#include "tv_denoising.hpp" + +int main(int argc, char** argv) +{ + // Check if an image file path is provided as an argument + if (argc != 2) + { + std::cerr << "Usage: ./denoiser " << std::endl; + return 1; + } + + // Read the image + cv::Mat image = cv::imread(argv[1], cv::IMREAD_GRAYSCALE); + + // Check if the image was successfully loaded + if (image.empty()) + { + std::cerr << "Failed to read the image." << std::endl; + return 1; + } + + TVDenoising(image, 0.02, 10); + + // Display and save the denoised image + cv::imshow("Denoised Image", image); + cv::waitKey(0); + cv::imwrite("denoised_image.jpg", image); + + return 0; +}