Page 1 of 1
Remove background to take text
Posted: 2014-05-30T01:07:44-07:00
by alone76816
I have an image as below, name of image "res.png":
I use this command:
"convert res.png -blur 0x0.5 -contrast-stretch 50x0%% -unsharp 0x2 z.png"
result is:

I don't know to how i remove background to take text. Anybody help me, please !
I use an other way:
"convert res.png -edge 1 -negate -normalize -colorspace Gray -blur 0x.5 -contrast-stretch 0x50% y.png"
Then, i have an image:
I want an image with "white background" and "black text", help me, please, please, please !
Re: Remove background to take text
Posted: 2014-05-30T01:46:47-07:00
by snibgo
Most of your pixels should be white. "-contrast-stretch 50x0%%" makes half of them black.
"-contrast-stretch 2x90%%" works better.
Re: Remove background to take text
Posted: 2014-05-30T10:09:11-07:00
by fmw42
If on unix (Linus or Mac OSX or Windows with Cygwin) see my script textcleaner at the link below. If on pure Windows see the IM function -lat.
try something like
Code: Select all
convert image -lat 25x25+10% result
Re: Remove background to take text
Posted: 2014-06-01T17:18:10-07:00
by alone76816
Thank for "
snibgo" and "
fmw42", thank you very much !
I used
fmw42' code:
Code: Select all
convert image -lat 25x25+10% result
then, this result:

I want remove black background, because my image must black text and white background, or white text and black background. I don't know how i do it.
And, how can i convert image from black to white and from white to black ?
Re: Remove background to take text
Posted: 2014-06-01T17:29:57-07:00
by fmw42
Take your input and use -negate so that the input to textcleaner is always black text on white background. Then use -negate to convert back if need be. Textcleaner only works with dark text on light background
convert image -negate image_neg
textcleaner ..... image_neg result
See
http://www.imagemagick.org/script/comma ... php#negate
Re: Remove background to take text
Posted: 2014-06-02T23:27:20-07:00
by alone76816
Thank you, I will more research !
Re: Remove background to take text
Posted: 2014-06-02T23:36:28-07:00
by fmw42
try this
Code: Select all
textcleaner -g -e normalize -f 25 -o 10 res.png res_tc_f25_o10.png
Re: Remove background to take text
Posted: 2014-06-04T22:58:57-07:00
by alone76816
Why can I run that command ?
when I run, I gave an error:
"textcleaner: command not found"
How can i run this scripts, fmw42 ?
Re: Remove background to take text
Posted: 2014-06-05T09:24:44-07:00
by fmw42
You must be on Linux, Mac OS X or Windows with Cygwin. You have to download the script from my web site and follow the Pointers for set it up properly.
Re: Remove background to take text
Posted: 2014-06-06T01:14:17-07:00
by alone76816
Thank you, fmw42.
I tried this command, and it's ok:
Code: Select all
./textcleaner -g -e normalize -f 25 -o 10 res.png res_tc_f25_o10.png