In this project, I implement edge detection algorithms from scratch using c++.
Basically, I use Sobel operators to make convolutional operations with input images to compute the partial derivatives along x and y directions. After that, I compute the gradient image and then detect the edges at the peaks of gradient values. The total process follows this site (without pre-smoothing).
Here I implement two versions. For the canny edge detector, I convert the gradient image to the binary image and then perform Non-Maximum Suppression. For the simple version, I only consider horizontal and vertical directions. Note that these are basic re-implementation as I don't put much time into tuning the scale number for avoiding the overflow problem.
I use GNU Compiler Collection (GCC) to run the scripts on MacOS.
gcc script_name.cpp -o script_name
./script_name
Before running, the user needs to set up the WIDTH and HEIGHT of the image, the size of the filter, the threshold, and the name of the input image inside the script (Cannot pass the arguments at this version).
Original images are displayed as follows. Here we use the raw file as input and output. The image needs to be converted to jpg format for human vision.
The result is presented as follows:
Thanks professor Zheng for his patient instruction.