getting the edges of an image
getting the edges of an image
hi,
I am using Imagemagick on windows. how can i get the edges of an image such that the output should have
- white background
- sharp edges of the image
- edges should be in black color
- in the total image only the edges should be black and remaining else should be in white.
please tel me how can i get this?
I am using Imagemagick on windows. how can i get the edges of an image such that the output should have
- white background
- sharp edges of the image
- edges should be in black color
- in the total image only the edges should be black and remaining else should be in white.
please tel me how can i get this?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
It is very hard to prescribe some technique without seeing the image to which it will applied! Can you post a link to your image so that others can test with it? Find some free image hosting web site, post your image there, then link it here.
Please also read the following about posting including your IM version and platform.
Thanks.
Please also read the following about posting including your IM version and platform.
Thanks.
Re: getting the edges of an image
fmw42 wrote:It is very hard to prescribe some technique without seeing the image to which it will applied! Can you post a link to your image so that others can test with it? Find some free image hosting web site, post your image there, then link it here.
Please also read the following about posting including your IM version and platform.
Thanks.
okay. lets take the image in this link as an example
http://www.google.co.in/imgres?imgurl=h ... sch&itbs=1
it is an image of christmas tree. the output should be as the image in the below link
http://www.google.co.in/imgres?imgurl=h ... sch&itbs=1
ofcourse, the second image is not similar to the first one but the output should be as the second. also input can have any color as background unlike white in the first image but the output must have only white background and i need only the outline of the image(everything inside the image should be white as seen in the second image)
so please tell me how can i do this using imagemagick!!!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
Your first link is malformed, chopped off or for some reason does not work.
Re: getting the edges of an image
fmw42 wrote:Your first link is malformed, chopped off or for some reason does not work.
the first link is working. it is the image of a christmas tree with green filled inside.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
Code: Select all
Not Found
The requested URL /openclipart/clipart/recreation/holiday/christmas/christmas_tree_02_l.png was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I searched google and found another image. So here are two possible approaches.
Convert to grayscale, extract edges, flatten alpha channel to black:
convert christmas_tree_01.png -colorspace gray -edge 2 -background black -flatten christmas_tree_01_gray_edge2_flat.png
Extract alpha channel, extract edge from alpha channel:
convert christmas_tree_01.png -alpha extract -edge 2 christmas_tree_01_alpha_edge2.png
see
http://www.imagemagick.org/script/comma ... s.php#edge
http://www.imagemagick.org/Usage/transform/#edge
http://www.imagemagick.org/Usage/masking/#alpha_extract
Re: getting the edges of an image
yeah..correct . but I want the black thing into white and white into black.
what i mean to say is I want the image in such a way that not only its background should be in white color but also the color inside the tree should be white. that is, I want only the outline of the tree(in the black color) and rest of the image should be black.
what i mean to say is I want the image in such a way that not only its background should be in white color but also the color inside the tree should be white. that is, I want only the outline of the tree(in the black color) and rest of the image should be black.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
Simply add -negate.
convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
Re: getting the edges of an image
i am using Imagemagick 6.6.9 for windows. in that im not getting this alpha extraction command. when i try to execute this command it is showing an error of unrecognisable alpha...
how could i overcoem this problem?????
how could i overcoem this problem?????
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
this command
convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
should work fine on any IM platform that is using IM 6.6.9.x
I am not sure what is happening on your Windows system and am not a Windows user. Perhaps some other Windows user could verify if this works or not.
Alternate should be
convert christmas_tree_01.png -channel a -separate -edge2 -negate christmas_tree_01_alpha_edge2n.png
convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
should work fine on any IM platform that is using IM 6.6.9.x
I am not sure what is happening on your Windows system and am not a Windows user. Perhaps some other Windows user could verify if this works or not.
Alternate should be
convert christmas_tree_01.png -channel a -separate -edge2 -negate christmas_tree_01_alpha_edge2n.png
Re: getting the edges of an image
when i tried the above alternate command the output image is completely blank. I am using Windows 7 operating systems but i don't know why i am facing this type of problem.
but i want this command to work. it is key to our project. already some work has been halted. so please help me in accomplishing this?
but i want this command to work. it is key to our project. already some work has been halted. so please help me in accomplishing this?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: getting the edges of an image
I am sorry, I don't use Windows and don't know why you are having trouble. The above commands work fine for me on my Mac OSX IM 6.6.9.8 Q16. Perhaps you need to re-install IM. At this point, some other Windows user will have to try to help you or one of the IM developers.
What is your exact command and what is the exact error message?
Is it possible you have two version of IM installed and they are getting confused?
type
convert -version
what does it tell you?
Is it possible you are using the Windows convert command instead of the IM convert command -- you may need to rename the IM convert command to im_convert?
What is your exact command and what is the exact error message?
Is it possible you have two version of IM installed and they are getting confused?
type
convert -version
what does it tell you?
Is it possible you are using the Windows convert command instead of the IM convert command -- you may need to rename the IM convert command to im_convert?
Re: getting the edges of an image
I cannot reproduce this problem.
> convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
works as expected on my system (Windows XP)
I also tried with 6.6.8, same result.
> convert christmas_tree_01.png -alpha extract -edge 2 -negate christmas_tree_01_alpha_edge2n.png
works as expected on my system (Windows XP)
Code: Select all
>convert -version
Version: ImageMagick 6.6.9-8 2011-05-04 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
Re: getting the edges of an image
Works OK with 6.5.9 on Vista OK as well.
Re: getting the edges of an image
but why it is not working for my operating system(windows 7 32-bit)?
when i type the above commands in my pc for the above image it is showing a blank image(complete black or complete white).
when i type the above commands in my pc for the above image it is showing a blank image(complete black or complete white).