65 #include <config_auto.h> 69 #include "allheaders.h" 71 #define L_BUF_SIZE 512 75 static const l_int32 num_linear = 25;
76 static const l_int32 basic_linear[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
77 12, 13, 14, 15, 20, 21, 25, 30, 31, 35, 40, 41, 45, 50, 51};
105 PROCNAME(
"selaAddBasic");
109 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
115 for (i = 0; i < num_linear; i++) {
116 size = basic_linear[i];
121 for (i = 0; i < num_linear; i++) {
122 size = basic_linear[i];
131 for (i = 2; i <= 5; i++) {
192 PROCNAME(
"selaAddHitMiss");
196 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
332 PROCNAME(
"selaAddDwaLinear");
336 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
339 for (i = 2; i < 64; i++) {
344 for (i = 2; i < 64; i++) {
371 l_int32 i, f1, f2, prevsize, size;
374 PROCNAME(
"selaAddDwaCombs");
378 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
382 for (i = 4; i < 64; i++) {
385 if (size == prevsize)
387 selectComposableSels(i, L_HORIZ, NULL, &selh);
389 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dh", size);
392 L_ERROR(
"selh not made for i = %d\n", procName, i);
394 selectComposableSels(i, L_VERT, NULL, &selv);
396 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dv", size);
399 L_ERROR(
"selv not made for i = %d\n", procName, i);
445 l_int32 i, j, w, xc, yc;
446 l_float64 pi, halfpi, radincr, radang;
448 PIX *pixc, *pixm, *pixt;
450 PTA *pta1, *pta2, *pta3, *pta4;
453 PROCNAME(
"selaAddCrossJunctions");
456 return (
SELA *)ERROR_PTR(
"hlsize not > 0", procName, NULL);
457 if (norient < 1 || norient > 8)
458 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", procName, NULL);
462 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
466 halfpi = 3.1415926535 / 2.0;
467 radincr = halfpi / (l_float64)norient;
468 w = (l_int32)(2.2 * (L_MAX(hlsize, mdist) + 0.5));
475 for (i = 0; i < norient; i++) {
483 radang = (l_float32)i * radincr;
499 for (j = 0; j < 4; j++) {
500 angle = radang + (j - 0.5) * halfpi;
501 pixSetPixel(pixc, xc + (l_int32)(mdist * cos(angle)),
502 yc + (l_int32)(mdist * sin(angle)), 0xff000000);
510 snprintf(name,
sizeof(name),
"sel_cross_%d", i);
526 pixWriteDebug(
"/tmp/lept/sel/xsel1.png", pixt, IFF_PNG);
527 pixDisplay(pixt, 0, 100);
530 pixWriteDebug(
"/tmp/lept/sel/xsel2.png", pixt, IFF_PNG);
531 pixDisplay(pixt, 500, 100);
570 l_int32 i, j, k, w, xc, yc;
571 l_float64 pi, halfpi, radincr, jang, radang;
572 l_float64 angle[3], dist[3];
573 PIX *pixc, *pixm, *pixt;
575 PTA *pta1, *pta2, *pta3;
578 PROCNAME(
"selaAddTJunctions");
581 return (
SELA *)ERROR_PTR(
"hlsizel not > 1", procName, NULL);
582 if (norient < 1 || norient > 8)
583 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", procName, NULL);
587 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
591 halfpi = 3.1415926535 / 2.0;
592 radincr = halfpi / (l_float32)norient;
593 w = (l_int32)(2.4 * (L_MAX(hlsize, mdist) + 0.5));
600 for (i = 0; i < norient; i++) {
601 for (j = 0; j < 4; j++) {
602 jang = (l_float32)j * halfpi;
610 radang = (l_float32)i * radincr;
613 jang + radang + halfpi);
625 angle[0] = radang + jang - halfpi;
626 angle[1] = radang + jang + 0.5 * halfpi;
627 angle[2] = radang + jang + 1.5 * halfpi;
628 dist[0] = 0.8 * mdist;
629 dist[1] = dist[2] = mdist;
630 for (k = 0; k < 3; k++) {
631 pixSetPixel(pixc, xc + (l_int32)(dist[k] * cos(angle[k])),
632 yc + (l_int32)(dist[k] * sin(angle[k])),
641 snprintf(name,
sizeof(name),
"sel_cross_%d", 4 * i + j);
658 pixWriteDebug(
"/tmp/lept/sel/tsel1.png", pixt, IFF_PNG);
659 pixDisplay(pixt, 0, 100);
662 pixWriteDebug(
"/tmp/lept/sel/tsel2.png", pixt, IFF_PNG);
663 pixDisplay(pixt, 500, 100);
686 static const char *sel_4_1 =
" x" 689 static const char *sel_4_2 =
" x" 692 static const char *sel_4_3 =
" o " 695 static const char *sel_4_4 =
" o " 698 static const char *sel_4_5 =
" ox" 701 static const char *sel_4_6 =
" o " 704 static const char *sel_4_7 =
" xx" 707 static const char *sel_4_8 =
" x" 710 static const char *sel_4_9 =
"o x" 715 static const char *sel_8_1 =
" x " 718 static const char *sel_8_2 =
" x " 721 static const char *sel_8_3 =
"o " 724 static const char *sel_8_4 =
"o " 727 static const char *sel_8_5 =
"o x" 730 static const char *sel_8_6 =
"o " 733 static const char *sel_8_7 =
" x " 736 static const char *sel_8_8 =
" x " 739 static const char *sel_8_9 =
"ox " 744 static const char *sel_48_1 =
" xx" 747 static const char *sel_48_2 =
"o x" 884 PROCNAME(
"selMakePlusSign");
886 if (size < 3 || linewidth > size)
887 return (
SEL *)ERROR_PTR(
"invalid input", procName, NULL);
l_ok selSetOrigin(SEL *sel, l_int32 cy, l_int32 cx)
selSetOrigin()
l_ok selectComposableSizes(l_int32 size, l_int32 *pfactor1, l_int32 *pfactor2)
selectComposableSizes()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()
SEL * selCreateFromColorPix(PIX *pixs, const char *selname)
PTA * generatePtaLineFromPt(l_int32 x, l_int32 y, l_float64 length, l_float64 radang)
generatePtaLineFromPt()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok pixRenderPta(PIX *pix, PTA *pta, l_int32 op)
pixRenderPta()
SELA * sela4ccThin(SELA *sela)
sela4ccThin()
SELA * selaAddCrossJunctions(SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag)
selaAddCrossJunctions()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok pixSetAll(PIX *pix)
pixSetAll()
l_ok selaWriteStream(FILE *fp, SELA *sela)
selaWriteStream()
PIX * pixScaleBySampling(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBySampling()
l_ok ptaJoin(PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend)
ptaJoin()
l_ok pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
SELA * sela8ccThin(SELA *sela)
sela8ccThin()
SELA * selaAddTJunctions(SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag)
selaAddTJunctions()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
SELA * selaAddDwaCombs(SELA *sela)
selaAddDwaCombs()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
SELA * selaAddHitMiss(SELA *sela)
selaAddHitMiss()
SEL * selCreate(l_int32 height, l_int32 width, const char *name)
selCreate()
SEL * selCreateBrick(l_int32 h, l_int32 w, l_int32 cy, l_int32 cx, l_int32 type)
selCreateBrick()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixRenderLine(PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op)
pixRenderLine()
SEL * selMakePlusSign(l_int32 size, l_int32 linewidth)
selMakePlusSign()
SELA * selaCreate(l_int32 n)
selaCreate()
l_ok selaAddSel(SELA *sela, SEL *sel, const char *selname, l_int32 copyflag)
selaAddSel()
SELA * selaAddBasic(SELA *sela)
selaAddBasic()
SELA * sela4and8ccThin(SELA *sela)
sela4and8ccThin()
SELA * selaAddDwaLinear(SELA *sela)
selaAddDwaLinear()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
SEL * selCreateFromPix(PIX *pix, l_int32 cy, l_int32 cx, const char *name)
selCreateFromPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIX * selaDisplayInPix(SELA *sela, l_int32 size, l_int32 gthick, l_int32 spacing, l_int32 ncols)
selaDisplayInPix()
l_ok selSetElement(SEL *sel, l_int32 row, l_int32 col, l_int32 type)
selSetElement()
SEL * selCreateFromString(const char *text, l_int32 h, l_int32 w, const char *name)
selCreateFromString()