fill black color for an outline
fill black color for an outline
Hi!!
I have a image with white background and a number with black outline. I need to fill the number with black colour without disturbing the background. How can I achieve this?
I have a image with white background and a number with black outline. I need to fill the number with black colour without disturbing the background. How can I achieve this?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: fill black color for an outline
Please identify your version of IM and platform and upload your image to dropbox.com and put the link here. We cannot help without seeing the image and figuring out what needs to be done.
One approach might be to use -floodfill or -draw "... floodfill". See
http://www.imagemagick.org/Usage/color_ ... dfill_draw
http://www.imagemagick.org/Usage/color_ ... #floodfill
See also viewtopic.php?f=1&t=9620
One approach might be to use -floodfill or -draw "... floodfill". See
http://www.imagemagick.org/Usage/color_ ... dfill_draw
http://www.imagemagick.org/Usage/color_ ... #floodfill
See also viewtopic.php?f=1&t=9620
Re: fill black color for an outline
Started using imagemagick yesterday....should have posted the image...here it is...
https://www.dropbox.com/s/bofcu28v7l0uhro/out.png?dl=0
https://www.dropbox.com/s/bofcu28v7l0uhro/out.png?dl=0
Last edited by Amused23 on 2015-09-24T23:48:08-07:00, edited 1 time in total.
Re: fill black color for an outline
My imagemagick version is ImageMagick 6.7.7-10 and i am on ubuntu 14.04
Re: fill black color for an outline
is it possible to fill colour without giving the coordinates of the number?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: fill black color for an outline
I cannot download since you made it to require your login information. You should upload to the public folder on dropbox so no login is needed
Re: fill black color for an outline
If it is not possible to fill the numbers...is it possible to extract the numbers? I need this for Optical Character Recognition.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: fill black color for an outline
An obvious method to fill the numbers is:
1. Floodfill with red from top-left.
2. Floodfill with red from top-right.
3. Change white into black.
4. Floodfill with white from top-left.
5. Floodfill with white from top-right.
1. Floodfill with red from top-left.
2. Floodfill with red from top-right.
3. Change white into black.
4. Floodfill with white from top-left.
5. Floodfill with white from top-right.
snibgo's IM pages: im.snibgo.com
Re: fill black color for an outline
Hi..i am new to imagemagick...could you put that as commands? I would really appreciate it.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: fill black color for an outline
Somewhat similar to user snibgo's suggestion.
1) pad the image all around with 1 pixel of white
2) floodfill at the top left corner to replace white with red
3) replace white with black
4) replace red with white
5) shave 1 pixel all around the image to get back to original size
6) output result
(Note: your image has a dark column at around the second column from the left which is why I padded with white to avoid getting only one column of red in my step 2 and snibgo's step 1)
see
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#shave
http://www.imagemagick.org/Usage/color_basics/#opaque
http://www.imagemagick.org/Usage/color_ ... dfill_draw
http://www.imagemagick.org/Usage/color_ ... #floodfill
1) pad the image all around with 1 pixel of white
2) floodfill at the top left corner to replace white with red
3) replace white with black
4) replace red with white
5) shave 1 pixel all around the image to get back to original size
6) output result
(Note: your image has a dark column at around the second column from the left which is why I padded with white to avoid getting only one column of red in my step 2 and snibgo's step 1)
Code: Select all
convert out.png -bordercolor white -border 1 \
-fill red -draw "color 0,0 floodfill" \
-fill black -opaque white \
-fill white -opaque red \
-shave 1x1 \
result.png
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#shave
http://www.imagemagick.org/Usage/color_basics/#opaque
http://www.imagemagick.org/Usage/color_ ... dfill_draw
http://www.imagemagick.org/Usage/color_ ... #floodfill
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: fill black color for an outline
Yes, that's a better way. I hadn't seen that dark column.
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: fill black color for an outline
I first tried your method and that was when I saw the black column, since the red stopped there and did not fill all the white. So that was why I decided to pad and do only one floodfill and then shave again.snibgo wrote:Yes, that's a better way. I hadn't seen that dark column.
Re: fill black color for an outline
Thank you ...that worked like a charm!! I have a problem I don't understand. I first tried
https://www.dropbox.com/s/pvb5l1itdj73rhd/out.png?dl=0
and I got this result https://www.dropbox.com/s/as3elqdz77417zi/bw.png?dl=0. The yellow / orange colour is removed.
But when i try the same command on https://www.dropbox.com/s/7t315s2c9ee1pj6/out3.png?dl=0
I get https://www.dropbox.com/s/g63zieo4836mxuv/bw3.png?dl=0. The green colour remains.
How to get rid of the any background colour for the letters
Code: Select all
convert -white-threshold 50% on
and I got this result https://www.dropbox.com/s/as3elqdz77417zi/bw.png?dl=0. The yellow / orange colour is removed.
But when i try the same command on https://www.dropbox.com/s/7t315s2c9ee1pj6/out3.png?dl=0
I get https://www.dropbox.com/s/g63zieo4836mxuv/bw3.png?dl=0. The green colour remains.
How to get rid of the any background colour for the letters