Start tv_denoising implementation
This commit is contained in:
31
src/tv_denoising.cu
Normal file
31
src/tv_denoising.cu
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime.h>
|
||||
#include <device_launch_parameters.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
|
||||
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<float>(0), width * height * sizeof(float), cudaMemcpyHostToDevice);
|
||||
|
||||
|
||||
// Free the GPU memory
|
||||
cudaFree(d_image);
|
||||
}
|
Reference in New Issue
Block a user