When implementing libGOCR, the question arised: should we use grayscale? Is black and white enough? What about colors? We decided to use black and white only, since it seemed more than enough, and saved memory. Later, it was realized that color would be essential to some recognition systems -- specially if you want to use libGOCR to recognize something other than plain text. The design was changed, and now libGOCR support these image types3.4:
Type | Symbol | Pixel size |
Black & white | GOCR_BW | 1 |
Grayscale | GOCR_GRAY | 2 |
Color | GOCR_COLOR | 4 |
User-defined | GOCR_OTHER | - |
You may only access the image indirectly.
The whole point of using an image is that you can access pixels individually, so, after several conferences and hundreds of emails, we decided that yes, we would have pixels in our images. Ok, the joke was not funny.
To support the different image types, a slight hack was done in the gocrImageData structure, which contains the individual pixel data (section 3.2.3 has info about it, but you definitely don't need to know). In fact, you only won: you can access any image type just as if it's the type you want; that is, suppose the image loaded is in color, but you want to work in black and white: you can. The functions are:
for ( i = 0; i < img->width; i++ )
Each pixel has three fields that may be used as flags. They are boolean variables, and to access them use:
int gocr_pixelSetMark1 ( gocrImage *image, int x, int y,
int gocr_pixelSetMark2 ( gocrImage *image, int x, int y,
int gocr_pixelSetMark3 ( gocrImage *image, int x, int y,