mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2025-01-14 06:00:59 +00:00
Merge pull request #1037 from anshul1912/master
[IMPROVEMENT]Remove multiple RGB to grey conversion while OCR
This commit is contained in:
commit
5df1dbb922
@ -1,5 +1,6 @@
|
|||||||
0.88(2018-10-24) (unreleased)
|
0.88(2018-10-24) (unreleased)
|
||||||
-----------------
|
-----------------
|
||||||
|
- Optimize: Remove multiple RGB to grey conversion in OCR.
|
||||||
- Fix: Update UTF8Proc to 2.2.0
|
- Fix: Update UTF8Proc to 2.2.0
|
||||||
- Fix: Warn instead of fatal when a 0xFF marker is missing
|
- Fix: Warn instead of fatal when a 0xFF marker is missing
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ BOX* ignore_alpha_at_edge(png_byte *alpha, unsigned char* indata, int w, int h,
|
|||||||
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h, struct image_copy *copy)
|
char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* indata,int w, int h, struct image_copy *copy)
|
||||||
{
|
{
|
||||||
// uncomment the below lines to output raw image as debug.png iteratively
|
// uncomment the below lines to output raw image as debug.png iteratively
|
||||||
//save_spupng("debug.png", indata, w, h, palette, alpha, 16);
|
// save_spupng("debug.png", indata, w, h, palette, alpha, 16);
|
||||||
|
|
||||||
PIX *pix = NULL;
|
PIX *pix = NULL;
|
||||||
PIX *cpix = NULL;
|
PIX *cpix = NULL;
|
||||||
@ -244,20 +244,21 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
|
|||||||
ppixel++;
|
ppixel++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out);
|
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
|
#ifdef OCR_DEBUG
|
||||||
{
|
{
|
||||||
char str[128] = "";
|
char str[128] = "";
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
sprintf(str,"temp/file_c_%d.jpg",i);
|
sprintf(str,"temp/file_c_%d.jpg",i);
|
||||||
printf("Writing file_c_%d.jpg\n", 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++;
|
i++;
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
if (cpix_gs==NULL)
|
||||||
tess_ret=-1;
|
tess_ret=-1;
|
||||||
else
|
else
|
||||||
@ -273,7 +274,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
|
|||||||
pixDestroy(&cpix_gs);
|
pixDestroy(&cpix_gs);
|
||||||
pixDestroy(&color_pix);
|
pixDestroy(&color_pix);
|
||||||
pixDestroy(&color_pix_out);
|
pixDestroy(&color_pix_out);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user