diff --git a/src/tv_denoising.cu b/src/tv_denoising.cu new file mode 100644 index 0000000..b312b45 --- /dev/null +++ b/src/tv_denoising.cu @@ -0,0 +1,31 @@ +#include +#include +#include +#include + + +extern "C" void TVDenoising(cv::Mat& image, float lambda, int maxIterations) +{ + // Convert the image to float precision + cv::Mat floatImage; + image.convertTo(floatImage, CV_32F); + + // Get image dimensions + int width = image.cols; + int height = image.rows; + + // Calculate the number of blocks and threads per block + dim3 blockSize(16, 16); + dim3 gridSize((width + blockSize.x - 1) / blockSize.x, (height + blockSize.y - 1) / blockSize.y); + + // Allocate GPU memory for the image + float* d_image; + cudaMalloc(&d_image, width * height * sizeof(float)); + + // Copy the image data from host to device + cudaMemcpy(d_image, floatImage.ptr(0), width * height * sizeof(float), cudaMemcpyHostToDevice); + + + // Free the GPU memory + cudaFree(d_image); +}