Bug with conv2
2 views (last 30 days)
Show older comments
Nick Cooper
on 24 Oct 2019
Answered: Bruno Luong
on 30 Oct 2019
![image_2019_10_24T18_30_29_919Z.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/244893/image_2019_10_24T18_30_29_919Z.png)
Here is a sample convolution performed with the built in function conv2. Unless I am completely crazy, this is not even close to the correct answer? Based on that image and kernel, I was expecting the output to be: [3 5 4; 9 0 6; 1 7 3]. Does anyone know of issues with conv2, or have insight to share?
0 Comments
Accepted Answer
Ajay Pattassery
on 30 Oct 2019
Edited: Ajay Pattassery
on 30 Oct 2019
The above output from conv2 with the argument as 'valid' is expected.
If you are computing in the paper the kernel needs to be flipped and then slid over the image I.
The resultant kernel will be
0 0 0
0 0 0
0 0 1
Then the output will be,
3 7 8
7 2 9
3 8 0
0 Comments
More Answers (1)
Bruno Luong
on 30 Oct 2019
The answer is correct. May be you expect the result with sliding sum with unflip kernel which is of course wrong.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!