diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index 30579f4c..c002c940 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -1,5 +1,6 @@ 0.88(2018-10-24) (unreleased) ----------------- +- Optimize: Remove multiple RGB to grey conversion in OCR. - Fix: Update UTF8Proc to 2.2.0 - Fix: Warn instead of fatal when a 0xFF marker is missing diff --git a/src/lib_ccx/ocr.c b/src/lib_ccx/ocr.c index d30f1f2e..7e51fcc9 100644 --- a/src/lib_ccx/ocr.c +++ b/src/lib_ccx/ocr.c @@ -244,20 +244,21 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i ppixel++; } } - + BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out); + //Converting image to grayscale for OCR to avoid issues with transparency + cpix_gs = pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0); #ifdef OCR_DEBUG { char str[128] = ""; static int i = 0; sprintf(str,"temp/file_c_%d.jpg",i); printf("Writing file_c_%d.jpg\n", i); - pixWrite(str, pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0), IFF_JFIF_JPEG); + pixWrite(str, cpix_gs, IFF_JFIF_JPEG); i++; } #endif - cpix_gs = pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0); // Abhinav95: Converting image to grayscale for OCR to avoid issues with transparency if (cpix_gs==NULL) tess_ret=-1; else @@ -273,7 +274,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i pixDestroy(&cpix_gs); pixDestroy(&color_pix); pixDestroy(&color_pix_out); - + return NULL; } }