我尝试使用 NPP 创建一个“不锐化蒙版”,但我的图像没有锐化,只是在某些区域更亮了一点。知道这段代码有什么问题吗?
npp::loadImage("Lena.pgm", hostSrc);
// put two copies of the image in GPU memory
// one we'll turn into the unsharp mask
npp::ImageNPP_8u_C1 deviceSrc(hostSrc);
npp::ImageNPP_8u_C1 deviceUnsharpMask(hostSrc);
// 5x5 box for mask
NppiSize maskSize = {5, 5};
// create ROI based on image size and mask size
NppiSize maskedROI = {deviceSrc.width() - maskSize.width + 1,
deviceSrc.height() - maskSize.height + 1};
// allocate device blurred image
npp::ImageNPP_8u_C1 deviceBlurred(maskedROI.width, maskedROI.height);
NppiPoint anchor = {0, 0};
// run box filter
nppiFilterBox_8u_C1R(deviceSrc.data(), deviceSrc.pitch(),
deviceBlurred.data(), deviceBlurred.pitch(),
maskedROI, maskSize, anchor);
// subtract the masked image from the scratch image
eStatusNPP = nppiSub_8u_C1IRSfs(deviceBlurred.data(), deviceBlurred.pitch(),
deviceUnsharpMask.data(), deviceUnsharpMask.pitch(),
maskedROI, 1);
// now add the mask to the src image
eStatusNPP = nppiAdd_8u_C1IRSfs(deviceUnsharpMask.data(), deviceUnsharpMask.pitch(),
deviceSrc.data(), deviceSrc.pitch(),
maskedROI, 0);
// then copy back to host and save to file