How do I perform a normal convolution?

asked 2018-05-10 15:59:04 -0500

filter2D does something really weird. When I use a 1x1 kernel with a value of [1] on a floating point black and white image I don't get the same image back. Instead I get a different matrix with a lot of infinite values. What is this voodoo magic and how do I perform a convolution like it is defined in wikipedia?

edit retag flag offensive close merge delete


Are you trying to write a convolution method by yourself?

eshirima gravatar imageeshirima ( 2018-05-10 16:24:24 -0500 )edit

Do you have code to share regarding this identity convolution? Please do.

I tried this and it works on a 8UC1 format image:

kernel = np.ones((1, 1), np.float32)
dst = cv2.filter2D(src, -1, kernel)
sjhalayka gravatar imagesjhalayka ( 2018-05-10 16:46:59 -0500 )edit

I figured it out but this wonderful forum website won't let me post it. OpenCV was not dealing with floating point values that were too high properly and would convert them to infinity despite the matrix format not changing.

halfpotato gravatar imagehalfpotato ( 2018-05-10 17:56:24 -0500 )edit

but this wonderful forum website won't let me post it. Can you describe more clearly what is preventing you from posting your code? What problem is it? Is it a problem with this website, or a privilege (website feature) that is currently not available to you because you are new to this site? If the code is short, just edit your question, and surround the code with back-ticks ("`")

rwong gravatar imagerwong ( 2018-05-10 22:07:57 -0500 )edit