I have a 7x7 px image matrix. I want to use the Canny algorithm to detect edges. Below is my code:
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main()
{
Mat src_img;
Mat src = (Mat_ <float>(7, 7) <<
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 255, 0, 0, 0,
0, 0, 255, 255, 255, 0, 0,
0, 255, 255, 0, 255, 255, 0,
0, 0, 255, 255, 255, 0, 0,
0, 0, 0, 255, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0);
src.convertTo(src, CV_8U);
GaussianBlur(src, src, Size(3, 3), 0.1, 0.1);
Mat output;
Canny(src, output, 300, 700, 3, true);
cout << output << endl;
waitKey(0);
return 0;
}
I want to perform this algorithm by theorical formulas step-by-step. According to this link OpenCV: Canny Edge Detector, I can perform Gaussian filter and gradient strength but I cannot perform the remaining steps because I don’t know how to calculate the arctan(0/0). Can you help me perform the remaining steps of the Canny algorithm step-by-step looking exacty the same result in the code? I need to understand this algorithm clearly and thoroughly.
The image after Gaussian filtering is not changed. So, below is the gradient strength of the image that I calculated: