Closed HJH0303 closed 4 months ago
@HJH0303 Thank you for pointing out the good point!
As you mentioned, the filter2D function applies a correlation using the specified filter.
I understand that correlation and convolution are often used interchangeably in this field, so I'll make sure to specify which one it is in exams to prevent any misunderstandings :) However, to keep things clear, I always point out the original filtering operation we need to use.
For instance, in this scenario, to calculate the gradient x, we subtract the pixel intensity on the right from that on the left. Similarly, for the gradient y, we subtract the top pixel intensity from the bottom. (so, flipping the filter is not necessary in this case).
However, if I use the other specified function 'convolution' which performs convolutional operation,
lenna_grad_x = convolution(lenna_gaussia, h_x)
then, to obtain the gradient_x, you need to flip the original kernel to achieve the expected outcome.
Thank you
@yjyoo3312 Thank you for your detailed answer :)
@yjyoo3312 I have a questions in lecture 3 In lecture slide, Sobel filter of Sx is $
\begin{bmatrix}-1&0&1\\-2&0&2\\ -1&0&1 \end{bmatrix}
$ and Sy is $\begin{bmatrix}1&2&1\\0&0&0\\ -1&-2&-1 \end{bmatrix}
$ But in the source code of lecture 3, you used filter2D without filpping the Sobel kernel. I heard that cv2.filter2D does actually compute correlation, not the convolution. OpenCV doc: https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#filter2dSo I was wondering if the kernel of the filter doesn't have to flip?