Separate the red and black texts into 2 graphic files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
philhung0704
Posts: 1
Joined: 2016-09-06T23:50:10-07:00
Authentication code: 1151

Separate the red and black texts into 2 graphic files

Post by philhung0704 »

Hi All,

I am new to ImageMagicK, I have a image with 2 color texts, one is black and the other is red
is it possible we can use ImageMagicK to separate these 2 color texts into 2 bmp files??

Code: Select all

convert d:\de\2pages.bmp -fuzz 45%% -fill white +opaque red d:\de\2pages_red_45.bmp
I tried the above code, you can find the image files from the below links.
you can see the texts with distortion after conversion.

the original image
https://drive.google.com/file/d/0B_bGsy ... sp=sharing

the converted images
https://drive.google.com/file/d/0B_bGsy ... sp=sharing
https://drive.google.com/file/d/0B_bGsy ... sp=sharing

is it any other way, for example, we can "detect" the red texts and "chop" this area saving as a image file??

thanks for your help in advance!!!!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Separate the red and black texts into 2 graphic files

Post by snibgo »

philhung0704 wrote:I have a image with 2 color texts, one is black and the other is red
No you don't. The red and black characters have anti-aliasing of weird colours: orange, gray, cyan and so on.

EDIT: My point is that you can't do this simply by colours, because you don't know if a gray pixel belongs to the red text or the black text.

So you need to define more precisely what you need to do.
snibgo's IM pages: im.snibgo.com
Post Reply