how to draw an outline for a given image
how to draw an outline for a given image
Can anyone suggest me how to draw outline for an image in C#, image is of any shape.
Thanks.
Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
Please always provide your IM version and platform. What do you mean by outline? edges in an image? or just the outside borders?
Please show an example of what you want.
Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
I have moved this topic to the User's forum.
Please show an example of what you want.
Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
I have moved this topic to the User's forum.
Re: how to draw an outline for a given image
Thanks for the reply, for now i am not using any IM version, would like to know if by using IM is it possible to draw border by removing extra white spaces around image. I am trying to detect actual image and draw border/outline around that image (shape can be varied based on input).
For example, for a flower image. I would like to draw outline around that flower.
Sorry I didn't find any tool to attach images here that shows an example of what I need.
For example, for a flower image. I would like to draw outline around that flower.
Sorry I didn't find any tool to attach images here that shows an example of what I need.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
Can you provide an example image? You can post to some free hosting service such as dropbox.com and put the URL here. Is the background of your flower image outside the flower a constant color or near-constant color. If not, background removal is rather hard with a cluttered background. Imagemagick does not have any direct function for the latter or the following.
See
http://clippingmagic.com/
https://www.microsoft.com/en-us/researc ... rabCut.pdf
http://docs.opencv.org/3.1.0/d8/d83/tut ... #gsc.tab=0
See
http://clippingmagic.com/
https://www.microsoft.com/en-us/researc ... rabCut.pdf
http://docs.opencv.org/3.1.0/d8/d83/tut ... #gsc.tab=0
Re: how to draw an outline for a given image
Thank you for the reply, yes background color is constant color.
For example, take your profile pic as input. I need to draw outline only around hat and magic wand, and remove extra white space around that.
For example, take your profile pic as input. I need to draw outline only around hat and magic wand, and remove extra white space around that.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: how to draw an outline for a given image
Trimming off a constant-colour border is trivial: "-trim" does the job.
Drawing an edge around something is easy: "-edge 1".
There are many variations on these basic techniques.
For many example of simple usage of ImageMagick, see the usage pages: http://www.imagemagick.org/Usage/ .
Drawing an edge around something is easy: "-edge 1".
There are many variations on these basic techniques.
For many example of simple usage of ImageMagick, see the usage pages: http://www.imagemagick.org/Usage/ .
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
Here is a simple example in command line. I do not know C#
input:
The -fuzz 1% is not needed here since the background is exactly constant. But if you started with JPG, then the background would not be a perfectly flat colored. So you can use -fuzz XX% to allow some percent difference in the background color.
input:
Code: Select all
convert A_image.gif -colorspace gray -edge 1 -fuzz 1% -trim +repage A_image_edge.gif
The -fuzz 1% is not needed here since the background is exactly constant. But if you started with JPG, then the background would not be a perfectly flat colored. So you can use -fuzz XX% to allow some percent difference in the background color.
Re: how to draw an outline for a given image
Thank you so much for the reply.
I need to remove edge exactly to shape 'A' leaving inside triangle as it is. need to have border around 'A' shape.
Thank you, will do more research on how to use.
I need to remove edge exactly to shape 'A' leaving inside triangle as it is. need to have border around 'A' shape.
Thank you, will do more research on how to use.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
Fill the hole with blue:
Or add a 1 pixel border of background white, floodfill the outside of the letter A with red from the top left corner, shave off the 1 pixel border, change non-red to white and red to black, extract edge, trim off the excess region around the outside of the A.
Unix syntax:
I used unix syntax, since you did not reply to my request to provide your IM version and platform! Syntax differs
Code: Select all
convert A_image.gif -fuzz 85% -fill "rgb(0,0,128)" -draw "color 75,75 floodfill" -alpha off -colorspace gray -edge 1 -fuzz 1% -trim +repage A_image_edge2.gif
Or add a 1 pixel border of background white, floodfill the outside of the letter A with red from the top left corner, shave off the 1 pixel border, change non-red to white and red to black, extract edge, trim off the excess region around the outside of the A.
Unix syntax:
Code: Select all
convert A_image.gif -bordercolor white -border 1 \
-fuzz 5% -fill "red" -draw "color 0,0 floodfill" -alpha off \
-shave 1x1 \
-fill white +opaque red -fill black -opaque red \
-edge 1 \
-fuzz 1% -trim +repage \
A_image_edge3.gif
I used unix syntax, since you did not reply to my request to provide your IM version and platform! Syntax differs
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
Please supply your image. You can upload to some place such as dropbox.com and put the URL here. Then we can better understand what you are trying to do.
Re: how to draw an outline for a given image
Please check the images
I have this
and I need this
cropped image is in image shape not regular rectangle or square
I have this
and I need this
cropped image is in image shape not regular rectangle or square
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
I have asked for you IM version and platform, but you have not provided it. Please always provide that. Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
If on IM 6, then
If on IM 7, then
If on IM 6, then
Code: Select all
convert 781c0085d6.jpg -bordercolor white -border 1 -fuzz 20% -fill none -draw "matte 0,0 floodfill" -shave 1x1 result.png
Code: Select all
magick 781c0085d6.jpg -bordercolor white -border 1 -fuzz 20% -fill none -draw "alpha 0,0 floodfill" -shave 1x1 result.png
Re: how to draw an outline for a given image
Thanks for the reply I will try the code...
About IM version, I am not using any IM version for now. I wanted to know if it possible with IM.
I would like to use C# version if possible.
About IM version, I am not using any IM version for now. I wanted to know if it possible with IM.
I would like to use C# version if possible.
Re: how to draw an outline for a given image
Is it possible to get rid of the black color part that is outside of the image
here is the result i got (I am using IM7 for this result)
here is the result i got (I am using IM7 for this result)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to draw an outline for a given image
What was your exact code? What is your IM version and platform? Why do you not answer this question?
Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
What do you get from
Your output should be transparent. If you tried to save as JPG, then that is the issue. JPG does not support transparency. Use PNG or TIFF.
Please read the top-most post in this forum at viewtopic.php?f=1&t=9620.
What do you get from
Code: Select all
convert -version