Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2013-07-24T02:34:36-07:00
Hello
I was looking for a way to convert my silhouette images into a stencil outline. Is there a way to do this correctly?
I have tried taking my silhouette image and applied the following 2 commands:
convert image.png -edge .5 -blur 0x.5 image_new.png
convert image_new.png -negate image_final.png
And I get a pretty decent image created with the black silhouette fill removed and just a black outline border.
It does leave a bit of noise though around the border edges and the images are not super clean.
I was just wondering if there is a better way to do this. I'm probably doing it all wrong
Thank you
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Bonzo
Posts: 2971 Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England
Post
by Bonzo » 2013-07-24T07:50:54-07:00
How about resizing the original, negating, change the black to transparent it then compositing it with gravity center back over the original?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-07-24T09:09:53-07:00
How about posting a link to your input image so we can see what you are trying to do.
Bonzo
Posts: 2971 Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England
Post
by Bonzo » 2013-07-24T10:19:06-07:00
My method did not work very well:
Code: Select all
convert input.gif ( input.gif -thumbnail 90% -negate -transparent black ) -gravity center -composite output.gif
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2013-07-24T19:56:15-07:00
Thanks Bonzo.
I tried what you suggested but as you mentioned, it didn't come out very well
Cheers
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2013-07-24T19:59:35-07:00
your image does not have a pure white outside (though it is not visible to eye). But if you threshold at 99% you will see it is "dirty". Also the boundary is antialiased.
try this
convert qlq.png -alpha off -gravity center -bordercolor white -border 5 -morphology edgeout diamond:1 -shave 5x5 -negate outline1.png
or
convert qlq.png -alpha off -gravity center -bordercolor white -border 5 -morphology edgein diamond:1 -shave 5x5 -negate outline2.png
see
http://www.imagemagick.org/Usage/morphology/#difference
Or if you want binary, then
convert qlq.png -alpha off -gravity center -bordercolor white -border 5 -morphology edgeout diamond:1 -shave 5x5 -threshold 15% -negate outline3.png
robocop
Posts: 32 Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789
Post
by robocop » 2013-10-17T15:30:22-07:00
Sorry for the super late reply.
Thanks very much! The last one worked pretty well.
I appreciate the help
Thank you
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS