2

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 Answer 1

3

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

1
  • Unfortunately it does not apply to all images I have. A command that works very good is: -colorspace Gray -morphology EdgeOut Diamond:3 -negate -threshold 90%% -define morphology:compose=Lighten -morphology Convolve "Blur:0x1>" The problem is that I have some noise left in the images, some "scattered" black dots, that I would like to remove. Any ideas?
    – BlasterGod
    Commented Dec 13, 2023 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.