55 #include <config_auto.h>
59 #include "allheaders.h"
138 const char *sequence,
143 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
150 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
152 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
156 sarraySplitString(sa, sequence,
"+");
158 pdfout = (dispsep < 0) ? 1 : 0;
161 return (
PIX *)ERROR_PTR(
"sequence not valid", __func__, NULL);
174 for (i = 0; i < nops; i++) {
181 sscanf(&op[1],
"%d.%d", &w, &h);
187 sscanf(&op[1],
"%d.%d", &w, &h);
193 sscanf(&op[1],
"%d.%d", &w, &h);
198 sscanf(&op[1],
"%d.%d", &w, &h);
203 nred = strlen(op) - 1;
204 for (j = 0; j < nred; j++)
205 level[j] = op[j + 1] -
'0';
206 for (j = nred; j < 4; j++)
214 sscanf(&op[1],
"%d", &fact);
220 sscanf(&op[1],
"%d", &border);
232 pixDisplay(pix1, x, 0);
244 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
303 const char *sequence,
308 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
315 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
317 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
321 sarraySplitString(sa, sequence,
"+");
323 pdfout = (dispsep < 0) ? 1 : 0;
327 return (
PIX *)ERROR_PTR(
"sequence not valid", __func__, NULL);
340 for (i = 0; i < nops; i++) {
347 sscanf(&op[1],
"%d.%d", &w, &h);
353 sscanf(&op[1],
"%d.%d", &w, &h);
359 sscanf(&op[1],
"%d.%d", &w, &h);
364 sscanf(&op[1],
"%d.%d", &w, &h);
369 nred = strlen(op) - 1;
370 for (j = 0; j < nred; j++)
371 level[j] = op[j + 1] -
'0';
372 for (j = nred; j < 4; j++)
380 sscanf(&op[1],
"%d", &fact);
386 sscanf(&op[1],
"%d", &border);
398 pixDisplay(pix1, x, 0);
410 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
450 const char *sequence,
455 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
462 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
464 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
468 sarraySplitString(sa, sequence,
"+");
470 pdfout = (dispsep < 0) ? 1 : 0;
474 return (
PIX *)ERROR_PTR(
"sequence not valid", __func__, NULL);
487 for (i = 0; i < nops; i++) {
494 sscanf(&op[1],
"%d.%d", &w, &h);
500 sscanf(&op[1],
"%d.%d", &w, &h);
506 sscanf(&op[1],
"%d.%d", &w, &h);
511 sscanf(&op[1],
"%d.%d", &w, &h);
516 nred = strlen(op) - 1;
517 for (j = 0; j < nred; j++)
518 level[j] = op[j + 1] -
'0';
519 for (j = nred; j < 4; j++)
527 sscanf(&op[1],
"%d", &fact);
533 sscanf(&op[1],
"%d", &border);
545 pixDisplay(pix1, x, 0);
557 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
597 const char *sequence,
602 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
609 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
611 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
615 sarraySplitString(sa, sequence,
"+");
617 pdfout = (dispsep < 0) ? 1 : 0;
621 return (
PIX *)ERROR_PTR(
"sequence not valid", __func__, NULL);
634 for (i = 0; i < nops; i++) {
641 sscanf(&op[1],
"%d.%d", &w, &h);
647 sscanf(&op[1],
"%d.%d", &w, &h);
653 sscanf(&op[1],
"%d.%d", &w, &h);
658 sscanf(&op[1],
"%d.%d", &w, &h);
663 nred = strlen(op) - 1;
664 for (j = 0; j < nred; j++)
665 level[j] = op[j + 1] -
'0';
666 for (j = nred; j < 4; j++)
674 sscanf(&op[1],
"%d", &fact);
680 sscanf(&op[1],
"%d", &border);
692 pixDisplay(pix1, x, 0);
704 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
736 l_int32 nops, i, j, nred, fact, valid, w, h, netred, border;
738 l_int32 intlogbase2[5] = {1, 2, 3, 0, 4};
741 return ERROR_INT(
"sa not defined", __func__, FALSE);
747 for (i = 0; i < nops; i++) {
760 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
765 if (w <= 0 || h <= 0) {
766 lept_stderr(
"*** op: %s; w = %d, h = %d; must both be > 0\n",
775 nred = strlen(op) - 1;
777 if (nred < 1 || nred > 4) {
779 "*** op = %s; num reduct = %d; must be in {1,2,3,4}\n",
784 for (j = 0; j < nred; j++) {
785 level[j] = op[j + 1] -
'0';
786 if (level[j] < 1 || level[j] > 4) {
787 lept_stderr(
"*** op = %s; level[%d] = %d is invalid\n",
796 for (j = 0; j < nred; j++) {
797 level[j] = op[j + 1] -
'0';
804 if (sscanf(&op[1],
"%d", &fact) != 1) {
809 if (fact != 2 && fact != 4 && fact != 8 && fact != 16) {
810 lept_stderr(
"*** op = %s; invalid fact = %d\n", op, fact);
814 netred -= intlogbase2[fact / 4];
819 if (sscanf(&op[1],
"%d", &fact) != 1) {
825 lept_stderr(
"*** op = %s; must be first op\n", op);
830 lept_stderr(
"*** op = %s; invalid fact = %d\n", op, fact);
844 if (border != 0 && netred != 0) {
845 lept_stderr(
"*** op = %s; border added but net reduction not 0\n", op);
905 const char *sequence,
911 l_int32 nops, i, valid, w, h, x, pdfout;
917 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
919 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
923 sarraySplitString(sa, sequence,
"+");
925 pdfout = (dispsep < 0) ? 1 : 0;
929 for (i = 0; i < nops; i++) {
942 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
947 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
948 lept_stderr(
"*** op: %s; w = %d, h = %d; must both be odd\n",
957 if (op[1] !=
'w' && op[1] !=
'W' &&
958 op[1] !=
'b' && op[1] !=
'B') {
960 "*** op = %s; arg %c must be 'w' or 'b'\n", op, op[1]);
964 sscanf(&op[2],
"%d.%d", &w, &h);
965 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
966 lept_stderr(
"*** op: %s; w = %d, h = %d; must both be odd\n",
981 return (
PIX *)ERROR_PTR(
"sequence invalid", __func__, NULL);
993 for (i = 0; i < nops; i++) {
1000 sscanf(&op[1],
"%d.%d", &w, &h);
1006 sscanf(&op[1],
"%d.%d", &w, &h);
1012 sscanf(&op[1],
"%d.%d", &w, &h);
1018 sscanf(&op[1],
"%d.%d", &w, &h);
1024 sscanf(&op[2],
"%d.%d", &w, &h);
1025 if (op[1] ==
'w' || op[1] ==
'W')
1026 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_WHITE);
1028 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_BLACK);
1039 pixDisplay(pix1, x, dispy);
1047 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
1106 const char *sequence,
1112 l_int32 nops, i, valid, w, h, x, pdfout;
1118 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
1120 return (
PIX *)ERROR_PTR(
"sequence not defined", __func__, NULL);
1124 sarraySplitString(sa, sequence,
"+");
1126 pdfout = (dispsep < 0) ? 1 : 0;
1130 for (i = 0; i < nops; i++) {
1143 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
1148 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
1149 lept_stderr(
"*** op: %s; w = %d, h = %d; must both be odd\n",
1164 return (
PIX *)ERROR_PTR(
"sequence invalid", __func__, NULL);
1176 for (i = 0; i < nops; i++) {
1183 sscanf(&op[1],
"%d.%d", &w, &h);
1189 sscanf(&op[1],
"%d.%d", &w, &h);
1195 sscanf(&op[1],
"%d.%d", &w, &h);
1201 sscanf(&op[1],
"%d.%d", &w, &h);
1213 pixDisplay(pix1, x, dispy);
1221 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
PIX * pixReduceRankBinaryCascade(PIX *pixs, l_int32 level1, l_int32 level2, l_int32 level3, l_int32 level4)
pixReduceRankBinaryCascade()
PIX * pixColorMorph(PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize)
pixColorMorph()
PIX * pixCloseGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseGray()
PIX * pixDilateGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateGray()
PIX * pixOpenGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenGray()
PIX * pixErodeGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeGray()
PIX * pixOpenBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenBrick()
PIX * pixOpenCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenCompBrick()
PIX * pixCloseSafeCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeCompBrick()
PIX * pixCloseSafeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeBrick()
PIX * pixErodeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeBrick()
PIX * pixDilateBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrick()
PIX * pixDilateCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateCompBrick()
PIX * pixErodeCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeCompBrick()
PIX * pixTophat(PIX *pixs, l_int32 hsize, l_int32 vsize, l_int32 type)
pixTophat()
PIX * pixErodeCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeCompBrickDwa()
PIX * pixOpenCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenCompBrickDwa()
PIX * pixCloseCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseCompBrickDwa()
PIX * pixOpenBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenBrickDwa()
PIX * pixCloseBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseBrickDwa()
PIX * pixErodeBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeBrickDwa()
PIX * pixDilateCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateCompBrickDwa()
PIX * pixDilateBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrickDwa()
PIX * pixMorphSequenceDwa(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequenceDwa()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_int32 morphSequenceVerify(SARRAY *sa)
morphSequenceVerify()
PIX * pixColorMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy)
pixColorMorphSequence()
PIX * pixMorphCompSequenceDwa(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphCompSequenceDwa()
PIX * pixGrayMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy)
pixGrayMorphSequence()
PIX * pixMorphCompSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphCompSequence()
l_ok pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
l_ok pixSwapAndDestroy(PIX **ppixd, PIX **ppixs)
pixSwapAndDestroy()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
PIX * pixRemoveBorder(PIX *pixs, l_int32 npix)
pixRemoveBorder()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
void lept_stderr(const char *fmt,...)
lept_stderr()
char * stringRemoveChars(const char *src, const char *remchars)
stringRemoveChars()