Init main.cpp and tv_denoising.hpp
This commit is contained in:
12
include/tv_denoising.hpp
Normal file
12
include/tv_denoising.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
Author: Vargha Csongor Csaba
|
||||
Created: 2023-06-25 10:23:33
|
||||
*/
|
||||
#ifndef TV_DENOISING_H
|
||||
#define TV_DENOISING_H
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
extern "C" void TVDenoising(cv::Mat& image, float lambda, int maxIterations);
|
||||
|
||||
#endif // TV_DENOISING_H
|
44
src/main.cpp
Normal file
44
src/main.cpp
Normal file
@@ -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 <input_image>
|
||||
where <input_image> is the path to the image file you want to denoise.
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#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 <image_file_path>" << 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;
|
||||
}
|
Reference in New Issue
Block a user