Page 1 of 1

Create a Stencil Outline

Posted: 2013-07-24T02:34:36-07:00
by robocop
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 :lol:

Thank you

Re: Create a Stencil Outline

Posted: 2013-07-24T07:50:54-07:00
by Bonzo
How about resizing the original, negating, change the black to transparent it then compositing it with gravity center back over the original?

Re: Create a Stencil Outline

Posted: 2013-07-24T09:09:53-07:00
by fmw42
How about posting a link to your input image so we can see what you are trying to do.

Re: Create a Stencil Outline

Posted: 2013-07-24T10:19:06-07:00
by Bonzo
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

Re: Create a Stencil Outline

Posted: 2013-07-24T19:47:57-07:00
by robocop
Hi! Thank you for sharing your thoughts.

The original image:
http://img43.imageshack.us/img43/5357/qlq.png

After i apply the command:
convert image.png -edge .5 -blur 0x.5 image_new.png

I get this image:
http://img443.imageshack.us/img443/1766/enit.png

and after i apply the second command:
convert image_new.png -negate image_final.png

I end up getting the desired outline on the image:
http://img850.imageshack.us/img850/7831/xwqj.png

But as you can see it's a little dirty around the edges.

I was hoping to get an output something similar to this:
http://www.clker.com/cliparts/z/l/W/s/U ... ine-md.png

Thanks very much!

Re: Create a Stencil Outline

Posted: 2013-07-24T19:56:15-07:00
by robocop
Thanks Bonzo.

I tried what you suggested but as you mentioned, it didn't come out very well :) Cheers

Re: Create a Stencil Outline

Posted: 2013-07-24T19:59:35-07:00
by fmw42
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

Re: Create a Stencil Outline

Posted: 2013-10-17T15:30:22-07:00
by robocop
Sorry for the super late reply.

Thanks very much! The last one worked pretty well.

I appreciate the help
Thank you