C++ - how to apply separate filter

Hi,

I am trying to understand how shall I write a for loop to apply separate sobelx filter for a picture. I understand it is a -1, 0, 1 row vector, then multiple a 1,0,-1 coloumn vector, but i am not sure how shall I put it into the for loops for a 3 channel picture. Thanks!

unless this is some school assignment, you should not write loops.
instead, use sepFilter2D()

that’s wrong. those are not the components of a separated sobel filter. one of them is right, the other isn’t.

yes that’s the reason i ask for loop specifically.

[-1,0,1]
[-1
2
-1]

Thanks.

almost. it’s a composition of a derivative/gradient ([-1, 0, 1] or the reverse) in one direction, and a gaussian lowpass ([1,2,1]) in the other direction.

so could you share with me how to put into a for loop? thanks.