How to determine the correct value for the HasWhiteBackground property of the EqualizeBrightness method

Question

When using the EqualizeBrightness method of the ImageDocument object, what should the value of the HasWhiteBackground property be?

Answer

The HasWhiteBackground property specifies whether the image has a white background. If the value of this property is set to TRUE, FineReader Engine presumes that the background of the image is white and tries to even the brightness of the image so that the background becomes really white. If the background is not white, HasWhiteBackground should be set to FALSE.

The GetTextBackgroundColor method of the ImageDocument object can be used to determine if the background color is white, and then the value of the HasWhiteBackground property can be set based on that. The value of the BackgroundColor property of the GetTextBackgroundColor method is calculated as (red value) + (256 * green value) + (65536 * blue value), so for white, the value is 16777215.

C# code:

int white = 16777215;
int txtColor = 0, bgColor = 0;
imageDoc.GetTextBackgroundColor(0, 0, imageDoc.BlackWhiteImage.Width, imageDoc.BlackWhiteImage.Height, 0, out txtColor, out bgColor);
imageDoc.EqualizeBrightness(bgColor == white);

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.