I’m working with NPP library to build laplacian and gaussian pyramid.
When I have to upsize the image the result is different using nppiResizeSqrPixel_32f_C1R or nppiFilterGaussPyramidLayerUpBorder_32f_C1R.
In the case of nppiFilterGaussPyramidLayerUpBorder_32f_C1R it gives pixelated image.
Npp16u* Device;
Npp32f* gDevice32[liv], * rDevice32[livs], * lDevice32[liv];
Npp32f* pGaussianKernel;
int pitch[livs], primopitch;
size_t GaussianKernelBytes;
NppiSize size, re_size;
NppiPoint punto;
punto.x = 0;
punto.y = 0;
upSize.x = 0;
upSize.y = 0;
downSize.x = 0;
downSize.y = 0;
float* kernel;
kernel = (float*)malloc(sizeof(float) * (2 * radius + 1));
gaussian_kernel(kernel, sigma, radius);
GaussianKernelBytes = (sizeof(float) * 2 * radius) + (1 * sizeof(float));
CHECK_CUDA(cudaMalloc<Npp32f>(&pGaussianKernel, GaussianKernelBytes));
CHECK_CUDA(cudaMemcpy(pGaussianKernel, kernel, GaussianKernelBytes, cudaMemcpyHostToDevice));
device = nppiMalloc_16u_C1(width[0], height[0], &primopitch);
rDevice32[0] = nppiMalloc_32f_C1(width[0], height[0], &pitch[0]);
for (int i = 0; i < liv; i++)
{
rDevice32[i + 1] = nppiMalloc_32f_C1(width[i + 1], height[i + 1], &pitch[i+1]);
lDevice32[i] = nppiMalloc_32f_C1(width[i], height[i], &pitch[i]);
gDevice32[i] = nppiMalloc_32f_C1(width[i], height[i], &pitch[i]);
}
step = sizeof(uint16_t) * width[0];
CHECK_CUDA(cudaMemcpy2D(device, primopitch, image, step, step, height[0], cudaMemcpyHostToDevice));
CHECK_NPP(nppiConvert_16u32f_C1R(device, primopitch, rDevice32[0], pitch[0], size));
for (int i = liv - 1; i >= 0; i--)
{
factor = (double)(width[i]) / (double)width[i + 1];
size.height = height[i];
size.width = width[i];
re_size.height = height[i + 1];
re_size.width = width[i + 1];
CHECK_NPP(nppiFilterGaussPyramidLayerDownBorder_32f_C1R(rDevice32[i], (Npp32s)pitch[i], size, punto, rDevice32[i + 1], (Npp32s)pitch[i + 1], re_size, factor, (2 * radius) + 1, pGaussianKernel, NPP_BORDER_MIRROR));
}
for(int i=liv-1;i>=0;i--)
{
factor = (double)width[i] / (double)width[i + 1];
size.height = height[i + 1];
size.width = width[i + 1];
re_size.height = height[i];
re_size.width = width[i];
CHECK_NPP(nppiFilterGaussPyramidLayerUpBorder_32f_C1R(rDevice32[i + 1], (Npp32s)pitch[i + 1], size, punto, gDevice32[i], (Npp32s)pitch[i], re_size, factor, (2 * radius + 1), pGaussianKernel, NPP_BORDER_MIRROR));
CHECK_NPP(nppiSub_32f_C1R(gDevice32[i], pitch[i], rDevice32[i], pitch[i], lDevice32[i], pitch[i], re_size));
}
for (int i = liv - 1; i >= 0; i--)
{
size.height = height[i + 1];
size.width = width[i + 1];
re_size.height = height[i];
re_size.width = width[i];
CHECK_NPP(nppiFilterGaussPyramidLayerUpBorder_32f_C1R(rDevice32[i + 1], (Npp32s)pitch[i + 1], size, punto, rDevice32[i], (Npp32s)pitch[i], re_size, factor, (2 * radius + 1), pGaussianKernel, NPP_BORDER_MIRROR));
CHECK_NPP(nppiAdd_32f_C1IR(lDevice32[i], pitch[i], rDevice32[i], pitch[i], re_size));
}