Hi guys, recently i have read a journal, which implemented sobel mask based on 4 kernels : horizontal, vertical and right - left diagonal
I have tried to implement this method in opencv, and i use custom filter. Here is my code :
//Sobel edge detection dengan custom kernel
Mat kern1 = (Mat_<float>(3,3)<<-1.,0.,1.,-2.,0.,2.,-1.,0.,1.); // vertical kernel
Mat kern2 = (Mat_<float>(3,3)<<-1.,0.,1.,-2.,0.,2.,-1.,0.,1.); // horizontal kernel
Mat kern3 = (Mat_<float>(3,3)<<0.,1.,2.,-1.,0.,1.,-2.,-1.,0.); // left diagonal
Mat kern4 = (Mat_<float>(3,3)<<-2.,-1.,0.,-1.,0.,1.,0.,1.,2.); // right diagonal
Mat res;
filter2D(grayImg,res,grayImg.type(),kern2);
filter2D(res,res,res.type(),kern1);
filter2D(res,res,res.type(),kern3);
filter2D(res,res,res.type(),kern4);
namedWindow("sobel",0);
imshow("sobel",res);
Is it valid to do that ? Or am I missing something ? Thanks.