I’m trying to use median filter to perform a 3x3 filter on an image.
(Using nppiFilterMedian_8u_C3R for color image, nppiFilterMedian_8u_C1R for gray image, nppiFilterMedian_32f_C1R for depth map.)
I was able to run the code and I was successfully able to create the filtered image.
The problem is that the filter shifts the image slightly.
To be more specific, when using a 3x3 mask, the last 2 rows and the 2 two columns of the image are not masked, resulting an image that is shifted by 2 pixels upwards and 2 pixel towards left.
I’ve tried to set anchor point with negative value, and the image move upward.
So I tried to set anchor point with positive value, then it came out kernel error.
But nppi do not have the similar function nppiFilterMedianBorder().
ps. Accroding to this link(https://software.intel.com/en-us/node/503723), anchor cell is usuallay the mid of the mask(kernal). But when I set anchor point with any positive value (eg. just using (mask.x / 2 - 1, mask.y / 2 - 1)), there came a CUDA kernal error.
Not really an answer – just an extension to your question…
How do the NPPI functions perform a median filter on 3-channel images? The documentation does not say. I would guess you would convert to HSV and sort first on V, then on S, and then on H? I wish the documentation wasn’t so sparse.