ImageMagick Edge Detection - Picture To Line Drawing

139 Views Asked by At

I am trying to transform an image to line drawing, exactly like on this website (default settings):

https://tech-lagoon.com/imagechef/en/image-to-edge.html

I am using Image Magick to try to achieve the exact same results, but currently fail to do so. I have tried using canny edge filter or -edge 1 but the results are not as expected. The closest thing I have manage to achieve to the above website is the following command:

magick input.png -colorspace Gray -morphology EdgeOut Octagon -negate out.bmp

Here is my original image: enter image description here

Here is the image I am trying to obtain: (just black lines on a white background, and thick black lines, without "double outline" like you see in my obtained image, in the collar of the dog. I just want one line)

enter image description here

Here is what I get when I run the Image Magick command from above: enter image description here

Any suggestions to get the desired result? It would be even better if I could obtain the same image as the one from tech-lagoon but also remove all lines that are not black (for example the wall different color line, that is very thin)

EDIT 1: Trying various morphology got me a good result, but I still need some help. I need to "denoise" and remove scattered black dots.

The command that works is -colorspace Gray -morphology EdgeOut Diamond:3 -negate -threshold 90%% -define morphology:compose=Lighten -morphology Convolve "Blur:0x1>"

For the image: enter image description here

Gets me: enter image description here

I would like to "clean" it up a bit, because the lines are not perfect everywhere. Any ideas for denoising a bit and improving the black lines so they are more smooth?

1

There are 1 best solutions below

1
Mark Setchell On

The black lines you want seem to already be in the image. How about turning everything that is not black into white?

magick dog.png -fill white -fuzz 20% +opaque black result.png

enter image description here