00001
00002
00003
00004 void TessBaseAPI::ThresholdRect(const UINT8* imagedata,
00005 int bytes_per_pixel,
00006 int bytes_per_line,
00007 int left, int top,
00008 int width, int height,
00009 const int* thresholds,
00010 const int* hi_values) {
00011 IMAGELINE line;
00012 page_image.create(width, height, 1);
00013 line.init(width);
00014
00015
00016
00017
00018
00019
00020 const UINT8* data = imagedata + top*bytes_per_line + left*bytes_per_pixel;
00021 for (int y = height - 1 ; y >= 0; --y) {
00022 const UINT8* pix = data;
00023 for (int x = 0; x < width; ++x, pix += bytes_per_pixel) {
00024 line.pixels[x] = 1;
00025 for (int ch = 0; ch < bytes_per_pixel; ++ch) {
00026 if (hi_values[ch] >= 0 && (pix[ch] > thresholds[ch]) == (hi_values[ch] == 0)) {
00027 line.pixels[x] = 0;
00028 break;
00029 }
00030 }
00031 }
00032 page_image.put_line(0, y, width, &line, 0);
00033 data += bytes_per_line;
00034 }
00035 }
00036