Create a page or tool which performs edge detection on a given image and, given a point, returns the distance from that point to the closest edge.
- Using
Canny edge detection
(openCV) +KNN
algorithm run from command line (terminal). - Using
Canny edge detection
(openCV) +KNN
algorithm withFlask
server.
Brief introduction :
- Canny edge detection steps -> Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed.
-
Apply Gaussian filter to smooth the image in order to remove the noise
-
Apply non-maximum suppression to get rid of spurious response to edge detection
-
Apply double threshold to determine potential edges
-
Track edge by hysteresis: Finalize the detection of edges by suppressing all the other edges that are weak and not connected to strong edges.
KNN algorithm
:
k-NN is a type of instance-based learning, or lazy learning, where the function is only approximated locally and all computation is deferred until function evaluation.
Both for classification and regression, a useful technique can be to assign weights to the contributions of the neighbors, so that the nearer neighbors contribute more to the average than the more distant ones.
[Taken from wikipedia] :
Explanation : test sample (green dot) should be classified either to blue squares or to red triangles. If k = 3 (solid line circle) it is assigned to the red triangles because there are 2 triangles and only 1 square inside the inner circle. If k = 5 (dashed line circle) it is assigned to the blue squares (3 squares vs. 2 triangles inside the outer circle).
- Edge detection in the browser using
tensorflow.js
[TODO - Currently in progress]
- Log on to following URL hosted on pythonanywhere.com using flask server :
-
We need to install latest version of Opencv.
Download here -
Run the cmd (terminal).
-
Download the project files using following command in the directory from where you need to run the script :
git clone https://github.com/souravs17031999/Edge-detection-Challenge
-
Change directory to
edge_detect_cmd
. -
Run the command using the following parameters as shown :
python edge_detection.py <image> <X> <Y>
positional arguments:
arguments | details |
---|---|
image | Image path |
X | x coordinate of user selected point |
Y | y coordinate of user selected point |
Note : closest edges are marked and shown.
⭐️ this Project if you liked it !