41 #include <config_auto.h>
45 #include "allheaders.h"
82 char *fname, *tail, *basename;
83 PIX *pixs, *pixg1, *pixg2, *pixb;
87 return ERROR_INT(
"dirin", __func__, 1);
89 return ERROR_INT(
"dirout", __func__, 1);
90 if (upscaling != 1 && upscaling != 2 && upscaling != 4)
91 return ERROR_INT(
"invalid upscaling factor", __func__, 1);
92 if (thresh <= 0) thresh = 180;
93 if (firstpage < 0) firstpage = 0;
94 if (npages < 0) npages = 0;
95 if (outformat != IFF_TIFF_G4)
100 return ERROR_INT(
"safiles not made", __func__, 1);
103 return ERROR_INT(
"no matching files in the directory", __func__, 1);
106 for (i = 0; i < nfiles; i++) {
108 if ((pixs =
pixRead(fname)) == NULL) {
109 L_WARNING(
"Couldn't read file %s\n", __func__, fname);
112 if (pixGetDepth(pixs) == 32)
117 if (pixGetDepth(pixg2) == 1) {
122 else if (upscaling == 2)
133 if (outformat == IFF_TIFF_G4) {
134 snprintf(buf,
sizeof(buf),
"%s/%s.tif", dirout, basename);
135 pixWrite(buf, pixb, IFF_TIFF_G4);
137 snprintf(buf,
sizeof(buf),
"%s/%s.png", dirout, basename);
138 pixWrite(buf, pixb, IFF_PNG);
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()
PIX * pixThresholdToBinary(PIX *pixs, l_int32 thresh)
pixThresholdToBinary()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixClone(PIX *pixs)
pixClone()
@ REMOVE_CMAP_TO_GRAYSCALE
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertRGBToLuminance(PIX *pixs)
pixConvertRGBToLuminance()
PIX * pixRead(const char *filename)
pixRead()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
SARRAY * getSortedPathnamesInDirectory(const char *dirname, const char *substr, l_int32 first, l_int32 nfiles)
getSortedPathnamesInDirectory()
PIX * pixScaleGray4xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray4xLIThresh()
PIX * pixScaleGray2xLIThresh(PIX *pixs, l_int32 thresh)
pixScaleGray2xLIThresh()
l_ok splitPathAtExtension(const char *pathname, char **pbasename, char **pextension)
splitPathAtExtension()
l_ok splitPathAtDirectory(const char *pathname, char **pdir, char **ptail)
splitPathAtDirectory()