41 #include "allheaders.h" 78 char *fname, *tail, *basename;
79 PIX *pixs, *pixg1, *pixg2, *pixb;
82 PROCNAME(
"convertFilesTo1bpp");
85 return ERROR_INT(
"dirin", procName, 1);
87 return ERROR_INT(
"dirout", procName, 1);
88 if (upscaling != 1 && upscaling != 2 && upscaling != 4)
89 return ERROR_INT(
"invalid upscaling factor", procName, 1);
90 if (thresh <= 0) thresh = 180;
91 if (firstpage < 0) firstpage = 0;
92 if (npages < 0) npages = 0;
93 if (outformat != IFF_TIFF_G4)
98 return ERROR_INT(
"safiles not made", procName, 1);
101 return ERROR_INT(
"no matching files in the directory", procName, 1);
104 for (i = 0; i < nfiles; i++) {
106 if ((pixs =
pixRead(fname)) == NULL) {
107 L_WARNING(
"Couldn't read file %s\n", procName, fname);
110 if (pixGetDepth(pixs) == 32)
115 if (pixGetDepth(pixg2) == 1) {
120 else if (upscaling == 2)
131 if (outformat == IFF_TIFF_G4) {
132 snprintf(buf,
sizeof(buf),
"%s/%s.tif", dirout, basename);
133 pixWrite(buf, pixb, IFF_TIFF_G4);
135 snprintf(buf,
sizeof(buf),
"%s/%s.png", dirout, basename);
136 pixWrite(buf, pixb, IFF_PNG);
PIX * pixConvertRGBToLuminance(PIX *pixs)
pixConvertRGBToLuminance()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
l_ok splitPathAtExtension(const char *pathname, char **pbasename, char **pextension)
splitPathAtExtension()
PIX * pixScaleGray4xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray4xLIThresh()
PIX * pixScaleGray2xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray2xLIThresh()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
PIX * pixClone(PIX *pixs)
pixClone()
void pixDestroy(PIX **ppix)
pixDestroy()
SARRAY * getSortedPathnamesInDirectory(const char *dirname, const char *substr, l_int32 first, l_int32 nfiles)
getSortedPathnamesInDirectory()
l_ok splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
PIX * pixRead(const char *filename)
pixRead()
l_ok convertFilesTo1bpp(const char *dirin, const char *substr, l_int32 upscaling, l_int32 thresh, l_int32 firstpage, l_int32 npages, const char *dirout, l_int32 outformat)
convertFilesTo1bpp()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()