# How to extract edge list/contour from image using Images.jl

**URL:** <https://discourse.julialang.org/t/how-to-extract-edge-list-contour-from-image-using-images-jl/25927>\
**Category:** General Usage\
**Tags:** images\
**Created:** [July 2, 2019, 2:12pm UTC](https://discourse.julialang.org/t/how-to-extract-edge-list-contour-from-image-using-images-jl/25927 "2019-07-02T14:12:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruszkipista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ruszkipista/32/7381_2.png) [@ruszkipista](https://discourse.julialang.org/u/ruszkipista)\
**Post date:** [July 2, 2019, 2:12pm UTC](https://discourse.julialang.org/t/how-to-extract-edge-list-contour-from-image-using-images-jl/25927/1 "2019-07-02T14:12:18Z")

</div>

I am new to Julia and image processing. I need to implement geometrical shape (e.g. triangle, rectangle) detection for a course assignment. I want to solve it using Julia only (not e.g. opencv)  
I found an article doing this in [.net](http://www.aforgenet.com/articles/shape_checker/) : - this gives idea if I have a list of objects extracted from the image, then with some calculation I can recognise simple shapes.  
I went through this book: Cudihins: Hands-On Computer Vision with Julia , but did not find help (or I did not understand what I need from there)

I got this far, a simple colored geometrical shapes image converted to a bitmap containing only the edges. How can I get a list of objects where each object has a list of edges? Or this result is a dead end and I need something else?

```julia
using Images, ImageFeatures, FileIO
img = Images.load(Images.download("http://www.aforgenet.com/articles/shape_checker/demo.png"))
gray_img = Gray.(img);
img_edges = canny(gray_img, (Percentile(97), Percentile(60)));
dx, dy=imgradients(gray_img, KernelFactors.ando5);
img_phase = phase(dx, dy);
centers, radii = hough_circle_gradient(img_edges, img_phase, 20:30);
img_demo = Float64.(img_edges); 
for c in centers img_demo[c] = 2; end
[img Gray.(img_demo)]

```

 ![shapes_col](https://global.discourse-cdn.com/julialang/original/3X/e/d/eddc7d49ce60085325da5e7fa27e072fdbfcacca.gif)

also tried this (continuing the above code):

```julia
using ImageFiltering
gx, gy = ImageFiltering.imgradients(Gray.(img_edges),KernelFactors.ando3, "replicate")
mag, grad_angle = Images.magnitude_phase(gx,gy)
#mag[mag .< 0.5] .= 0.0 # Threshold magnitude image
thinned = Images.thin_edges(mag, grad_angle)
[Gray.(mag) Gray.(thinned)]

```

 ![shapes_edg](https://global.discourse-cdn.com/julialang/original/3X/4/9/495cb0528c352cf1eabf76955ec70d2d72c33891.gif)  
but obviously I do not understand what I am doing.  
Please give me some pointers what/where to look for.

---

<div class="post-metadata">

**Author:** ![Giuliano\_Giannetti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giuliano_giannetti/32/11089_2.png) [@Giuliano\_Giannetti](https://discourse.julialang.org/u/Giuliano_Giannetti)\
**Post date:** [December 2, 2019, 9:51pm UTC](https://discourse.julialang.org/t/how-to-extract-edge-list-contour-from-image-using-images-jl/25927/2 "2019-12-02T21:51:42Z")

</div>

Seems no one does this here… in openCV it is easy

---

<div class="post-metadata">

**Author:** ![fmvin](https://avatars.discourse-cdn.com/v4/letter/f/b38774/32.png) [@fmvin](https://discourse.julialang.org/u/fmvin)\
**Post date:** [January 9, 2020, 3:25pm UTC](https://discourse.julialang.org/t/how-to-extract-edge-list-contour-from-image-using-images-jl/25927/3 "2020-01-09T15:25:59Z")

</div>

Please take a look at [this discussion](https://github.com/JuliaImages/Images.jl/issues/859) in Images.jl github project. Serious work is doing in this field now.
