62 #include "allheaders.h" 68 static const l_int32 num_linear = 25;
69 static const l_int32 basic_linear[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
70 12, 13, 14, 15, 20, 21, 25, 30, 31, 35, 40, 41, 45, 50, 51};
98 PROCNAME(
"selaAddBasic");
102 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
108 for (i = 0; i < num_linear; i++) {
109 size = basic_linear[i];
114 for (i = 0; i < num_linear; i++) {
115 size = basic_linear[i];
124 for (i = 2; i <= 5; i++) {
185 PROCNAME(
"selaAddHitMiss");
189 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
325 PROCNAME(
"selaAddDwaLinear");
329 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
332 for (i = 2; i < 64; i++) {
337 for (i = 2; i < 64; i++) {
364 l_int32 i, f1, f2, prevsize, size;
367 PROCNAME(
"selaAddDwaCombs");
371 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
375 for (i = 4; i < 64; i++) {
378 if (size == prevsize)
380 selectComposableSels(i, L_HORIZ, NULL, &selh);
381 selectComposableSels(i, L_VERT, NULL, &selv);
382 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dh", size);
384 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dv", size);
430 l_int32 i, j, w, xc, yc;
431 l_float64 pi, halfpi, radincr, radang;
433 PIX *pixc, *pixm, *pixt;
435 PTA *pta1, *pta2, *pta3, *pta4;
438 PROCNAME(
"selaAddCrossJunctions");
441 return (
SELA *)ERROR_PTR(
"hlsize not > 0", procName, NULL);
442 if (norient < 1 || norient > 8)
443 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", procName, NULL);
447 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
451 halfpi = 3.1415926535 / 2.0;
452 radincr = halfpi / (l_float64)norient;
453 w = (l_int32)(2.2 * (L_MAX(hlsize, mdist) + 0.5));
460 for (i = 0; i < norient; i++) {
468 radang = (l_float32)i * radincr;
484 for (j = 0; j < 4; j++) {
485 angle = radang + (j - 0.5) * halfpi;
486 pixSetPixel(pixc, xc + (l_int32)(mdist * cos(angle)),
487 yc + (l_int32)(mdist * sin(angle)), 0xff000000);
495 snprintf(name,
sizeof(name),
"sel_cross_%d", i);
511 pixWriteDebug(
"/tmp/lept/sel/xsel1.png", pixt, IFF_PNG);
512 pixDisplay(pixt, 0, 100);
515 pixWriteDebug(
"/tmp/lept/sel/xsel2.png", pixt, IFF_PNG);
516 pixDisplay(pixt, 500, 100);
555 l_int32 i, j, k, w, xc, yc;
556 l_float64 pi, halfpi, radincr, jang, radang;
557 l_float64 angle[3], dist[3];
558 PIX *pixc, *pixm, *pixt;
560 PTA *pta1, *pta2, *pta3;
563 PROCNAME(
"selaAddTJunctions");
566 return (
SELA *)ERROR_PTR(
"hlsizel not > 1", procName, NULL);
567 if (norient < 1 || norient > 8)
568 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", procName, NULL);
572 return (
SELA *)ERROR_PTR(
"sela not made", procName, NULL);
576 halfpi = 3.1415926535 / 2.0;
577 radincr = halfpi / (l_float32)norient;
578 w = (l_int32)(2.4 * (L_MAX(hlsize, mdist) + 0.5));
585 for (i = 0; i < norient; i++) {
586 for (j = 0; j < 4; j++) {
587 jang = (l_float32)j * halfpi;
595 radang = (l_float32)i * radincr;
598 jang + radang + halfpi);
610 angle[0] = radang + jang - halfpi;
611 angle[1] = radang + jang + 0.5 * halfpi;
612 angle[2] = radang + jang + 1.5 * halfpi;
613 dist[0] = 0.8 * mdist;
614 dist[1] = dist[2] = mdist;
615 for (k = 0; k < 3; k++) {
616 pixSetPixel(pixc, xc + (l_int32)(dist[k] * cos(angle[k])),
617 yc + (l_int32)(dist[k] * sin(angle[k])),
626 snprintf(name,
sizeof(name),
"sel_cross_%d", 4 * i + j);
643 pixWriteDebug(
"/tmp/lept/sel/tsel1.png", pixt, IFF_PNG);
644 pixDisplay(pixt, 0, 100);
647 pixWriteDebug(
"/tmp/lept/sel/tsel2.png", pixt, IFF_PNG);
648 pixDisplay(pixt, 500, 100);
671 static const char *sel_4_1 =
" x" 674 static const char *sel_4_2 =
" x" 677 static const char *sel_4_3 =
" o " 680 static const char *sel_4_4 =
" o " 683 static const char *sel_4_5 =
" ox" 686 static const char *sel_4_6 =
" o " 689 static const char *sel_4_7 =
" xx" 692 static const char *sel_4_8 =
" x" 695 static const char *sel_4_9 =
"o x" 700 static const char *sel_8_1 =
" x " 703 static const char *sel_8_2 =
" x " 706 static const char *sel_8_3 =
"o " 709 static const char *sel_8_4 =
"o " 712 static const char *sel_8_5 =
"o x" 715 static const char *sel_8_6 =
"o " 718 static const char *sel_8_7 =
" x " 721 static const char *sel_8_8 =
" x " 724 static const char *sel_8_9 =
"ox " 729 static const char *sel_48_1 =
" xx" 732 static const char *sel_48_2 =
"o x" 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()
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()
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()
static const l_int32 L_BUF_SIZE
SEL * selCreateFromString(const char *text, l_int32 h, l_int32 w, const char *name)
selCreateFromString()