Change the bold level of the text

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?".
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Change the bold level of the text

Post by user20157 »

Do you know any formula that i can use to reduce the bold level of the text(make it thinner and less dark) on this picture
http://imgur.com/OA6vKyN
to look similar to this :
http://i.stack.imgur.com/A2Dq2.png
Thank you very much,
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change the bold level of the text

Post by fmw42 »

The only thing I can suggest is to use -morphology dilate octagon:X followed by +level Yx100%

X is the size of the octagon shape for the -morphology to make the text thinner. Start with X=1 and try larger integers. Or use -morphology dilate disk:X, where X is a float.

See
http://www.imagemagick.org/Usage/morphology/#kernel
http://www.imagemagick.org/Usage/morphology/#basic


Y is the percent less dark you want, where 0% is full dark. So try Y=20% or something else as desired.


convert image -morphology dilate octagon:1 +level 20x100% result


But this will shrink your accent marks and perhaps even make them disappear.
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

yeah. It totally shrinks the image. Do you know anyway i can fix that?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change the bold level of the text

Post by fmw42 »

What do you mean by shrinks the image? The image dimensions should not change!

Once your text is in pixel format (versus vector data), it is impossible to change fonts until you have done OCR. All you can do is try to thin out the fonts if the fonts are too thick.
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

sorry i mean not reducing the accent mark.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change the bold level of the text

Post by fmw42 »

No, the thinning is global, so affects everything.

Is this not acceptable?

Code: Select all

convert OA6vKyN.png -alpha off -morphology dilate disk:1.3 result.png
Alternately, create the thinned result as above (or change the 1.3 to something else). Then create an image only of the accent marks from the original. Then combine them as the minimum graylevel of the two images after deleting the original. But that is only slightly better.

Code: Select all

convert OA6vKyN.png -alpha off \
\( -clone 0 -morphology dilate disk:1.3 \) \
\( -clone 0 -negate -morphology tophat disk:4.2 -negate -threshold 40% \
-define connected-components:area-threshold=20 \
-define connected-components:mean-color=true \
-connected-components 4 \) \
-delete 0 -evaluate-sequence min result.png
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

Yes. Your method produces better accuracy. But it can't still produce 100 % accuracy. When i took a screenshot from my wordpad program it produce 100 % accurarcy but even for images taken elsewhere with the same level of text thickness the accuracy is just about 70 %. It seems that i have to fix other image properties as well but i don't know what they are :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change the bold level of the text

Post by fmw42 »

Sorry, I do not understand what you have done to get 100% accuracy from Wordpad? I do not know any further way to improve your results.
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

i used Tesseract for extracting text from images. All i did to get 100% accuracy from Wordpad is to type the some words in Vietnamese into the Wordpad program and take a screenshot of it(printscreen). Afterwords i run the Tesseract:tesseract imagename filename -l vie and received 100% text accuracy.
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

This is the link to that image which i sent you on last posts: http://i.stack.imgur.com/A2Dq2.png
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Change the bold level of the text

Post by Bonzo »

Why not try OCR and re create the image?
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

what do you mean ?
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

I tried Tesseract
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Change the bold level of the text

Post by Bonzo »

OCR = Optical character recognition
user20157
Posts: 19
Joined: 2016-01-11T18:17:14-07:00
Authentication code: 1151

Re: Change the bold level of the text

Post by user20157 »

Post Reply