CUDA:实现使用NNP把图片数据直方图均值化
把图片数据直方图均值化是一种图像处理技术,它通过调整图像的亮度和对比度来增强图像的质量。下面是一个使用 CUDA 和 OpenCV 库实现图像直方图均值化的示例代码:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/cuda.hpp>
#include <opencv2/cudaimgproc.hpp>
using namespace cv;
int main() {
// Read the input image
Mat image = imread("input.jpg", IMREAD_GRAYSCALE);
if (image.empty()) {
std::cerr << "Failed to read the image" << std::endl;
return -1;
}
// Display the original image
imshow("Original Image", image);
// Convert the image to CUDA Mat
cuda::GpuMat d_image;
d_image.upload(image);
// Compute histogram
cuda::GpuMat d_hist;
cuda::calcHist(d_image, d_hist);
// Compute cumulative distribution func