Page 1 of 1

textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-25T07:43:11-07:00
by psnbproj
I am using textcleaner on mobile snaps of my notebook in which I write with five colored gel pens: blue, black, red, violet and green. The results are pretty good.
However the main color of a handwriting stroke gets mixed in with dots of other colors eg violet has blue, black etc. (This is especially bad with green.)

Is it possible to convert all the pixels of handwriting of one color completely to that color?

I am using

Code: Select all

textcleaner -e normalize -f 15 -o 5 -s 1 -S 2000 in.jpg out.jpg

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-25T11:11:09-07:00
by fmw42
Post your input image exampe to some place such as dropbox.com and put the URL here. I will need to test with your example to see what is going on. What version of IM and platform are you using?

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-25T19:16:48-07:00
by psnbproj
Hi Fred,
I want to digitize around 50 of my notebooks and your scripts are so useful. Thanks for sharing.
The input image is as follows. For this input file I have taken a snap on my mobile 8MP camera, done multicrop and reduced size.
https://www.dropbox.com/s/od89b77ipt0mt ... 0.jpg?dl=0

On this file I have run

Code: Select all

textcleaner -e normalize -f 15 -o 5 -s 1 -S 2000 in_q30.jpg out_q30.jpg
The output image is
https://www.dropbox.com/s/hnosas1seswq2 ... 0.jpg?dl=0

So what I am looking for here is: Is it possible to have all the pixels of pen strokes of a particular color in that color only?
(Other issues are also there: a) how to lighten the image b) convert, say, the light green to darker shade, c) pen-marks from backside are appearing which are not so jarring in the original etc.)

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-25T20:46:38-07:00
by fmw42
I will look at this further in the next few days. But you have increased the saturation 2000 %. So that is causing the colors to become different from the original. You have over-brightened the image by using -e normalize. Try -e stretch or none.

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-25T21:47:09-07:00
by psnbproj
Thanks.
-e stretch doesn't seem to make any difference. It's better with -e none, some of the background marks go. The brightness doesn't decrease though - so, how to retain some of the grayness of the original background? It is good on the eye.

I used -S 2000 with some trial and error, because with double saturation (-S 200) colors can barely be differentiated. (Note: I hardly know anything about image processing.)

If needed the original ~2MB snap is given below. (For the images given before I had used smaller jpg obtained with convert -quality 30. Otherwise I get huge pdfs for the full notebooks.):
https://www.dropbox.com/s/jkb6g97hvfdxy8p/in.jpg?dl=0

The ImageMagick I am using (from convert -version):
Version: ImageMagick 6.8.9-9 Q16 x86_64 2015-01-06
Features: DPC Modules OpenMP
Delegates: bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Platform: Ubuntu 15.04

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-26T01:02:32-07:00
by fmw42
try these 3 variations

Code: Select all

textcleaner -f 10 -o 5  in.jpg in_tc_f10_o5.jpg
textcleaner -f 10 -o 5 -b "gray90" -S 500  in.jpg in_tc_f10_o5_g90_S500.jpg
textcleaner -f 10 -o 5 -b "gray95" -S 500  in.jpg in_tc_f10_o5_g95_S500.jpg

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-26T02:53:41-07:00
by psnbproj
Thanks a lot, this's now much better. (I liked gray80.)

About the original query: Would it now be possible to convert each stroke into one color? Maybe, (I am being naive here), by locally determining which is the non-white dominant color and convert all contagious non-white pixels to that color? I guess this is tricky, because, as an example, the blue writing has large portions where the dominant color is blackish. Also, this could be problematic where two strokes of different colors overlap?

Re: textcleaner: multicolor text, each stroke of one color?

Posted: 2015-11-26T10:06:03-07:00
by fmw42
With the inconsistent coloring, I do not think that is possible. You would have to have a way to extract each separate color. You would likely have to reduce the number of colors first. Try my script kmeans. It can separate out layers (or separate images) for each color, but you have to tell it which colors you have. But it might break some colors in the original into two different final colors.

I also think you would get better results if your resolution were higher. Do you have higher quality scans?