What is the equivalent method in opencv for ndimage.convolve?
Closed this issue · 3 comments
Hi Utkarsh,
You did a great job. The fingerprint image after enhancement look great! I was trying to convert your python code into C#. I am using emgu.CV, the closest method to achieve the functionality of ndimage.convolve was using cv2.filter2D because this method is supported in C#.
The python code is as follow :
Gx = ndimage.convolve(Gxx,f)
and C# code is as follow
ConvolutionKernelF GxxKernal = new ConvolutionKernelF(f);
f= f.Flip(FlipType.Both);
CvInvoke.Filter2D(ToMatrix(Gxx), Gx, f, new Point(-1, -1), 0, BorderType.Reflect);
by using this parameter for Filter2D in openCV, I can get a close result to python however there are not equal.
Maybe Filter2D in OpenCV is not capable of producing the same result as in ndimage.convolve, do you know is there any other method in opencv that can produce the same convolution result as in ndimage.convolve? Thanks in advance!
this may be happening on the borders.. The default method for filter2D is BORDER_DEFAULT
which is a 101-reflective border of the original array. for example: gfedcb|abcdefgh|gfedcba
. The default method for ndimage.convolve
is also reflective border but in the documentation, they specify the implementation to be gfedcba|abcdefgh|hgfedcba
Here are the documentation links:
Opencv Filter2D: https://docs.opencv.org/3.4/d4/d86/group__imgproc__filter.html#ga27c049795ce870216ddfb366086b5a04
ndimage.convolve: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.convolve.html
Hope that answers the question
Thanks for your reply, I replace ndimage.convolve with Filter2D, the enhance image for both method are slightly different, I couldn't tell which one is more close to the original image since both enhance images have its own advantage. Anyway I would like to thank you once again with such a great job!
you are welcome. glad that you found this project useful.