55 #include "allheaders.h" 134 const char *sequence,
139 l_int32 nops, i, j, nred, fact, w, h, x, 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;
159 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
172 for (i = 0; i < nops; i++) {
179 sscanf(&op[1],
"%d.%d", &w, &h);
185 sscanf(&op[1],
"%d.%d", &w, &h);
191 sscanf(&op[1],
"%d.%d", &w, &h);
196 sscanf(&op[1],
"%d.%d", &w, &h);
201 nred = strlen(op) - 1;
202 for (j = 0; j < nred; j++)
203 level[j] = op[j + 1] -
'0';
204 for (j = nred; j < 4; j++)
212 sscanf(&op[1],
"%d", &fact);
218 sscanf(&op[1],
"%d", &border);
230 pixDisplay(pix1, x, 0);
242 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
301 const char *sequence,
306 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
312 PROCNAME(
"pixMorphCompSequence");
315 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
317 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
321 sarraySplitString(sa, sequence,
"+");
323 pdfout = (dispsep < 0) ? 1 : 0;
327 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, 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;
461 PROCNAME(
"pixMorphSequenceDwa");
464 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
466 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
470 sarraySplitString(sa, sequence,
"+");
472 pdfout = (dispsep < 0) ? 1 : 0;
476 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
489 for (i = 0; i < nops; i++) {
496 sscanf(&op[1],
"%d.%d", &w, &h);
502 sscanf(&op[1],
"%d.%d", &w, &h);
508 sscanf(&op[1],
"%d.%d", &w, &h);
513 sscanf(&op[1],
"%d.%d", &w, &h);
518 nred = strlen(op) - 1;
519 for (j = 0; j < nred; j++)
520 level[j] = op[j + 1] -
'0';
521 for (j = nred; j < 4; j++)
529 sscanf(&op[1],
"%d", &fact);
535 sscanf(&op[1],
"%d", &border);
547 pixDisplay(pix1, x, 0);
559 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
599 const char *sequence,
604 l_int32 nops, i, j, nred, fact, w, h, x, border, pdfout;
610 PROCNAME(
"pixMorphCompSequenceDwa");
613 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
615 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
619 sarraySplitString(sa, sequence,
"+");
621 pdfout = (dispsep < 0) ? 1 : 0;
625 return (
PIX *)ERROR_PTR(
"sequence not valid", procName, NULL);
638 for (i = 0; i < nops; i++) {
645 sscanf(&op[1],
"%d.%d", &w, &h);
651 sscanf(&op[1],
"%d.%d", &w, &h);
657 sscanf(&op[1],
"%d.%d", &w, &h);
662 sscanf(&op[1],
"%d.%d", &w, &h);
667 nred = strlen(op) - 1;
668 for (j = 0; j < nred; j++)
669 level[j] = op[j + 1] -
'0';
670 for (j = nred; j < 4; j++)
678 sscanf(&op[1],
"%d", &fact);
684 sscanf(&op[1],
"%d", &border);
696 pixDisplay(pix1, x, 0);
708 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
740 l_int32 nops, i, j, nred, fact, valid, w, h, netred, border;
742 l_int32 intlogbase2[5] = {1, 2, 3, 0, 4};
744 PROCNAME(
"morphSequenceVerify");
747 return ERROR_INT(
"sa not defined", procName, FALSE);
753 for (i = 0; i < nops; i++) {
766 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
767 fprintf(stderr,
"*** op: %s invalid\n", op);
771 if (w <= 0 || h <= 0) {
773 "*** op: %s; w = %d, h = %d; must both be > 0\n",
782 nred = strlen(op) - 1;
784 if (nred < 1 || nred > 4) {
786 "*** op = %s; num reduct = %d; must be in {1,2,3,4}\n",
791 for (j = 0; j < nred; j++) {
792 level[j] = op[j + 1] -
'0';
793 if (level[j] < 1 || level[j] > 4) {
794 fprintf(stderr,
"*** op = %s; level[%d] = %d is invalid\n",
803 for (j = 0; j < nred; j++) {
804 level[j] = op[j + 1] -
'0';
811 if (sscanf(&op[1],
"%d", &fact) != 1) {
812 fprintf(stderr,
"*** op: %s; fact invalid\n", op);
816 if (fact != 2 && fact != 4 && fact != 8 && fact != 16) {
817 fprintf(stderr,
"*** op = %s; invalid fact = %d\n", op, fact);
821 netred -= intlogbase2[fact / 4];
826 if (sscanf(&op[1],
"%d", &fact) != 1) {
827 fprintf(stderr,
"*** op: %s; fact invalid\n", op);
832 fprintf(stderr,
"*** op = %s; must be first op\n", op);
837 fprintf(stderr,
"*** op = %s; invalid fact = %d\n", op, fact);
845 fprintf(stderr,
"*** nonexistent op = %s\n", op);
851 if (border != 0 && netred != 0) {
853 "*** op = %s; border added but net reduction not 0\n", op);
913 const char *sequence,
919 l_int32 nops, i, valid, w, h, x, pdfout;
924 PROCNAME(
"pixGrayMorphSequence");
927 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
929 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
933 sarraySplitString(sa, sequence,
"+");
935 pdfout = (dispsep < 0) ? 1 : 0;
939 for (i = 0; i < nops; i++) {
952 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
953 fprintf(stderr,
"*** op: %s invalid\n", op);
957 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
959 "*** op: %s; w = %d, h = %d; must both be odd\n",
968 if (op[1] !=
'w' && op[1] !=
'W' &&
969 op[1] !=
'b' && op[1] !=
'B') {
971 "*** op = %s; arg %c must be 'w' or 'b'\n", op, op[1]);
975 sscanf(&op[2],
"%d.%d", &w, &h);
976 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
978 "*** op: %s; w = %d, h = %d; must both be odd\n",
986 fprintf(stderr,
"*** nonexistent op = %s\n", op);
993 return (
PIX *)ERROR_PTR(
"sequence invalid", procName, NULL);
1005 for (i = 0; i < nops; i++) {
1012 sscanf(&op[1],
"%d.%d", &w, &h);
1018 sscanf(&op[1],
"%d.%d", &w, &h);
1024 sscanf(&op[1],
"%d.%d", &w, &h);
1030 sscanf(&op[1],
"%d.%d", &w, &h);
1036 sscanf(&op[2],
"%d.%d", &w, &h);
1037 if (op[1] ==
'w' || op[1] ==
'W')
1038 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_WHITE);
1040 pix2 =
pixTophat(pix1, w, h, L_TOPHAT_BLACK);
1051 pixDisplay(pix1, x, dispy);
1059 snprintf(fname,
sizeof(fname),
"/tmp/lept/seq_output_%d.pdf",
1118 const char *sequence,
1124 l_int32 nops, i, valid, w, h, x, pdfout;
1129 PROCNAME(
"pixColorMorphSequence");
1132 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
1134 return (
PIX *)ERROR_PTR(
"sequence not defined", procName, NULL);
1138 sarraySplitString(sa, sequence,
"+");
1140 pdfout = (dispsep < 0) ? 1 : 0;
1144 for (i = 0; i < nops; i++) {
1157 if (sscanf(&op[1],
"%d.%d", &w, &h) != 2) {
1158 fprintf(stderr,
"*** op: %s invalid\n", op);
1162 if (w < 1 || (w & 1) == 0 || h < 1 || (h & 1) == 0 ) {
1164 "*** op: %s; w = %d, h = %d; must both be odd\n",
1172 fprintf(stderr,
"*** nonexistent op = %s\n", op);
1179 return (
PIX *)ERROR_PTR(
"sequence invalid", procName, NULL);
1191 for (i = 0; i < nops; i++) {
1198 sscanf(&op[1],
"%d.%d", &w, &h);
1204 sscanf(&op[1],
"%d.%d", &w, &h);
1210 sscanf(&op[1],
"%d.%d", &w, &h);
1216 sscanf(&op[1],
"%d.%d", &w, &h);
1228 pixDisplay(pix1, x, dispy);
1236 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()
PIX * pixRemoveBorder(PIX *pixs, l_int32 npix)
pixRemoveBorder()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
PIX * pixCloseSafeBrick(PIX *pixd, PIX *pixs, l_int32 hsize, l_int32 vsize)
pixCloseSafeBrick()
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()
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_ok pixSwapAndDestroy(PIX **ppixd, PIX **ppixs)
pixSwapAndDestroy()
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()
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 * 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()