55 #include "allheaders.h" 134 const char *sequence,
139 l_int32 nops, i, j, nred, fact, w, h, x, y, border, pdfout;
145 PROCNAME(
"pixMorphSequence");
148 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
150 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
154 sarraySplitString(sa, sequence,
"+");
156 pdfout = (dispsep < 0) ? 1 : 0;
160 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
173 for (i = 0; i < nops; i++) {
180 sscanf(&op[1],
"%d.%d", &w, &h);
186 sscanf(&op[1],
"%d.%d", &w, &h);
192 sscanf(&op[1],
"%d.%d", &w, &h);
197 sscanf(&op[1],
"%d.%d", &w, &h);
202 nred = strlen(op) - 1;
203 for (j = 0; j < nred; j++)
204 level[j] = op[j + 1] -
'0';
205 for (j = nred; j < 4; j++)
213 sscanf(&op[1],
"%d", &fact);
219 sscanf(&op[1],
"%d", &border);
231 pixDisplay(pix1, x, y);
243 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
302 const char *sequence,
307 l_int32 nops, i, j, nred, fact, w, h, x, y, border, pdfout;
313 PROCNAME(
"pixMorphCompSequence");
316 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
318 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
322 sarraySplitString(sa, sequence,
"+");
324 pdfout = (dispsep < 0) ? 1 : 0;
328 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
341 for (i = 0; i < nops; i++) {
348 sscanf(&op[1],
"%d.%d", &w, &h);
354 sscanf(&op[1],
"%d.%d", &w, &h);
360 sscanf(&op[1],
"%d.%d", &w, &h);
365 sscanf(&op[1],
"%d.%d", &w, &h);
370 nred = strlen(op) - 1;
371 for (j = 0; j < nred; j++)
372 level[j] = op[j + 1] -
'0';
373 for (j = nred; j < 4; j++)
381 sscanf(&op[1],
"%d", &fact);
387 sscanf(&op[1],
"%d", &border);
399 pixDisplay(pix1, x, y);
411 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
451 const char *sequence,
456 l_int32 nops, i, j, nred, fact, w, h, x, y, border, pdfout;
462 PROCNAME(
"pixMorphSequenceDwa");
465 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
467 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
471 sarraySplitString(sa, sequence,
"+");
473 pdfout = (dispsep < 0) ? 1 : 0;
477 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
490 for (i = 0; i < nops; i++) {
497 sscanf(&op[1],
"%d.%d", &w, &h);
503 sscanf(&op[1],
"%d.%d", &w, &h);
509 sscanf(&op[1],
"%d.%d", &w, &h);
514 sscanf(&op[1],
"%d.%d", &w, &h);
519 nred = strlen(op) - 1;
520 for (j = 0; j < nred; j++)
521 level[j] = op[j + 1] -
'0';
522 for (j = nred; j < 4; j++)
530 sscanf(&op[1],
"%d", &fact);
536 sscanf(&op[1],
"%d", &border);
548 pixDisplay(pix1, x, y);
560 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
600 const char *sequence,
605 l_int32 nops, i, j, nred, fact, w, h, x, y, border, pdfout;
611 PROCNAME(
"pixMorphCompSequenceDwa");
614 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
616 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
620 sarraySplitString(sa, sequence,
"+");
622 pdfout = (dispsep < 0) ? 1 : 0;
626 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
639 for (i = 0; i < nops; i++) {
646 sscanf(&op[1],
"%d.%d", &w, &h);
652 sscanf(&op[1],
"%d.%d", &w, &h);
658 sscanf(&op[1],
"%d.%d", &w, &h);
663 sscanf(&op[1],
"%d.%d", &w, &h);
668 nred = strlen(op) - 1;
669 for (j = 0; j < nred; j++)
670 level[j] = op[j + 1] -
'0';
671 for (j = nred; j < 4; j++)
679 sscanf(&op[1],
"%d", &fact);
685 sscanf(&op[1],
"%d", &border);
697 pixDisplay(pix1, x, y);
709 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
741 l_int32 nops, i, j, nred, fact, valid, w, h, netred, border;
743 l_int32 intlogbase2[5] = {1, 2, 3, 0, 4};
745 PROCNAME(
"morphSequenceVerify");
748 return ERROR_INT(
"sa not defined", procName, FALSE);
754 for (i = 0; i < nops; i++) {
767 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
768 fprintf(stderr,
"*** op: %s invalid\n", op);
772 if (w <= 0 || h <= 0) {
774 "*** op: %s; w = %d, h = %d; must both be > 0\n",
783 nred = strlen(op) - 1;
785 if (nred < 1 || nred > 4) {
787 "*** op = %s; num reduct = %d; must be in {1,2,3,4}\n",
792 for (j = 0; j < nred; j++) {
793 level[j] = op[j + 1] -
'0';
794 if (level[j] < 1 || level[j] > 4) {
795 fprintf(stderr,
"*** op = %s; level[%d] = %d is invalid\n",
804 for (j = 0; j < nred; j++) {
805 level[j] = op[j + 1] -
'0';
812 if (sscanf(&op[1],
"%d", &fact) != 1) {
813 fprintf(stderr,
"*** op: %s; fact invalid\n", op);
817 if (fact != 2 && fact != 4 && fact != 8 && fact != 16) {
818 fprintf(stderr,
"*** op = %s; invalid fact = %d\n", op, fact);
822 netred -= intlogbase2[fact / 4];
827 if (sscanf(&op[1],
"%d", &fact) != 1) {
828 fprintf(stderr,
"*** op: %s; fact invalid\n", op);
833 fprintf(stderr,
"*** op = %s; must be first op\n", op);
838 fprintf(stderr,
"*** op = %s; invalid fact = %d\n", op, fact);
846 fprintf(stderr,
"*** nonexistent op = %s\n", op);
852 if (border != 0 && netred != 0) {
854 "*** op = %s; border added but net reduction not 0\n", op);
914 const char *sequence,
920 l_int32 nops, i, valid, w, h, x, pdfout;
925 PROCNAME(
"pixGrayMorphSequence");
928 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
930 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
934 sarraySplitString(sa, sequence,
"+");
936 pdfout = (dispsep < 0) ? 1 : 0;
940 for (i = 0; i < nops; i++) {
953 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
954 fprintf(stderr,
"*** op: %s invalid\n", op);
958 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
960 "*** op: %s; w = %d, h = %d; must both be odd\n",
969 if (op[1] !=
'w' && op[1] !=
'W' &&
970 op[1] !=
'b' && op[1] !=
'B') {
972 "*** op = %s; arg %c must be 'w' or 'b'\n", op, op[1]);
976 sscanf(&op[2],
"%d.%d", &w, &h);
977 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
979 "*** op: %s; w = %d, h = %d; must both be odd\n",
987 fprintf(stderr,
"*** nonexistent op = %s\n", op);
994 return (
PIX *)ERROR_PTR(
"sequence invalid", procName, NULL);
1006 for (i = 0; i < nops; i++) {
1013 sscanf(&op[1],
"%d.%d", &w, &h);
1019 sscanf(&op[1],
"%d.%d", &w, &h);
1025 sscanf(&op[1],
"%d.%d", &w, &h);
1031 sscanf(&op[1],
"%d.%d", &w, &h);
1037 sscanf(&op[2],
"%d.%d", &w, &h);
1038 if (op[1] ==
'w' || op[1] ==
'W')
1039 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_WHITE);
1041 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_BLACK);
1052 pixDisplay(pix1, x, dispy);
1060 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
1119 const char *sequence,
1125 l_int32 nops, i, valid, w, h, x, pdfout;
1130 PROCNAME(
"pixColorMorphSequence");
1133 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1135 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
1139 sarraySplitString(sa, sequence,
"+");
1141 pdfout = (dispsep < 0) ? 1 : 0;
1145 for (i = 0; i < nops; i++) {
1158 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
1159 fprintf(stderr,
"*** op: %s invalid\n", op);
1163 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
1165 "*** op: %s; w = %d, h = %d; must both be odd\n",
1173 fprintf(stderr,
"*** nonexistent op = %s\n", op);
1180 return (
PIX *)ERROR_PTR(
"sequence invalid", procName, NULL);
1192 for (i = 0; i < nops; i++) {
1199 sscanf(&op[1],
"%d.%d", &w, &h);
1205 sscanf(&op[1],
"%d.%d", &w, &h);
1211 sscanf(&op[1],
"%d.%d", &w, &h);
1217 sscanf(&op[1],
"%d.%d", &w, &h);
1229 pixDisplay(pix1, x, dispy);
1237 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
PIX * pixCloseCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseCompBrickDwa()
PIX * pixDilateGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateGray()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
PIX * pixCloseGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseGray()
PIX * pixCloseSafeCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeCompBrick()
PIX * pixMorphCompSequenceDwa(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphCompSequenceDwa()
PIX * pixDilateBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrick()
PIX * pixTophat(PIX *pixs, l_int32 hsize, l_int32 vsize, l_int32 type)
pixTophat()
char * stringRemoveChars(const char *src, const char *remchars)
stringRemoveChars()
SARRAY * sarrayCreate(l_int32 n)
sarrayCreate()
PIX * pixDilateBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateBrickDwa()
l_int32 morphSequenceVerify(SARRAY *sa)
morphSequenceVerify()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
l_int32 pixSwapAndDestroy(PIX **ppixd, PIX **ppixs)
pixSwapAndDestroy()
PIX * pixRemoveBorder(PIX *pixs, l_int32 npix)
pixRemoveBorder()
PIX * pixCloseSafeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeBrick()
l_int32 pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
PIX * pixCloseBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseBrickDwa()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
PIX * pixErodeBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeBrickDwa()
char * sarrayGetString(SARRAY *sa, l_int32 index, l_int32 copyflag)
sarrayGetString()
PIX * pixDilateCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateCompBrick()
PIX * pixColorMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy)
pixColorMorphSequence()
l_int32 pixaConvertToPdf(PIXA *pixa, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout)
pixaConvertToPdf()
PIX * pixOpenCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenCompBrickDwa()
PIX * pixOpenBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenBrick()
l_int32 sarrayGetCount(SARRAY *sa)
sarrayGetCount()
PIX * pixGrayMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep, l_int32 dispy)
pixGrayMorphSequence()
PIX * pixExpandReplicate(PIX *pixs, l_int32 factor)
pixExpandReplicate()
PIX * pixOpenBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenBrickDwa()
PIX * pixErodeCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeCompBrick()
PIX * pixCopy(PIX *pixd, PIX *pixs)
pixCopy()
PIX * pixMorphSequenceDwa(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequenceDwa()
PIX * pixErodeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeBrick()
PIX * pixDilateCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixDilateCompBrickDwa()
PIX * pixErodeCompBrickDwa(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeCompBrickDwa()
PIX * pixReduceRankBinaryCascade(PIX *pixs, l_int32 level1, l_int32 level2, l_int32 level3, l_int32 level4)
pixReduceRankBinaryCascade()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIX * pixOpenGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenGray()
PIX * pixErodeGray(PIX *pixs, l_int32 hsize, l_int32 vsize)
pixErodeGray()
PIX * pixOpenCompBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixOpenCompBrick()
void sarrayDestroy(SARRAY **psa)
sarrayDestroy()
PIX * pixColorMorph(PIX *pixs, l_int32 type, l_int32 hsize, l_int32 vsize)
pixColorMorph()
PIX * pixMorphCompSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphCompSequence()