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};
107 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
113 for (i = 0; i < num_linear; i++) {
114 size = basic_linear[i];
119 for (i = 0; i < num_linear; i++) {
120 size = basic_linear[i];
129 for (i = 2; i <= 5; i++) {
192 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
330 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
333 for (i = 2; i < 64; i++) {
338 for (i = 2; i < 64; i++) {
365 l_int32 i, f1, f2, prevsize, size;
370 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
374 for (i = 4; i < 64; i++) {
377 if (size == prevsize)
379 selectComposableSels(i, L_HORIZ, NULL, &selh);
381 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dh", size);
384 L_ERROR(
"selh not made for i = %d\n", __func__, i);
386 selectComposableSels(i, L_VERT, NULL, &selv);
388 snprintf(name,
L_BUF_SIZE,
"sel_comb_%dv", size);
391 L_ERROR(
"selv not made for i = %d\n", __func__, i);
437 l_int32 i, j, w, xc, yc;
438 l_float64 pi, halfpi, radincr, radang;
440 PIX *pixc, *pixm, *pixt;
442 PTA *pta1, *pta2, *pta3, *pta4;
446 return (
SELA *)ERROR_PTR(
"hlsize not > 0", __func__, NULL);
447 if (norient < 1 || norient > 8)
448 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", __func__, NULL);
452 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
456 halfpi = 3.1415926535 / 2.0;
457 radincr = halfpi / (l_float64)norient;
458 w = (l_int32)(2.2 * (L_MAX(hlsize, mdist) + 0.5));
465 for (i = 0; i < norient; i++) {
473 radang = (l_float32)i * radincr;
489 for (j = 0; j < 4; j++) {
490 angle = radang + (j - 0.5) * halfpi;
491 pixSetPixel(pixc, xc + (l_int32)(mdist * cos(angle)),
492 yc + (l_int32)(mdist * sin(angle)), 0xff000000);
500 snprintf(name,
sizeof(name),
"sel_cross_%d", i);
516 pixWriteDebug(
"/tmp/lept/sel/xsel1.png", pixt, IFF_PNG);
517 pixDisplay(pixt, 0, 100);
520 pixWriteDebug(
"/tmp/lept/sel/xsel2.png", pixt, IFF_PNG);
521 pixDisplay(pixt, 500, 100);
560 l_int32 i, j, k, w, xc, yc;
561 l_float64 pi, halfpi, radincr, jang, radang;
562 l_float64 angle[3], dist[3];
563 PIX *pixc, *pixm, *pixt;
565 PTA *pta1, *pta2, *pta3;
569 return (
SELA *)ERROR_PTR(
"hlsizel not > 1", __func__, NULL);
570 if (norient < 1 || norient > 8)
571 return (
SELA *)ERROR_PTR(
"norient not in [1, ... 8]", __func__, NULL);
575 return (
SELA *)ERROR_PTR(
"sela not made", __func__, NULL);
579 halfpi = 3.1415926535 / 2.0;
580 radincr = halfpi / (l_float32)norient;
581 w = (l_int32)(2.4 * (L_MAX(hlsize, mdist) + 0.5));
588 for (i = 0; i < norient; i++) {
589 for (j = 0; j < 4; j++) {
590 jang = (l_float32)j * halfpi;
598 radang = (l_float32)i * radincr;
601 jang + radang + halfpi);
613 angle[0] = radang + jang - halfpi;
614 angle[1] = radang + jang + 0.5 * halfpi;
615 angle[2] = radang + jang + 1.5 * halfpi;
616 dist[0] = 0.8 * mdist;
617 dist[1] = dist[2] = mdist;
618 for (k = 0; k < 3; k++) {
619 pixSetPixel(pixc, xc + (l_int32)(dist[k] * cos(angle[k])),
620 yc + (l_int32)(dist[k] * sin(angle[k])),
629 snprintf(name,
sizeof(name),
"sel_cross_%d", 4 * i + j);
646 pixWriteDebug(
"/tmp/lept/sel/tsel1.png", pixt, IFF_PNG);
647 pixDisplay(pixt, 0, 100);
650 pixWriteDebug(
"/tmp/lept/sel/tsel2.png", pixt, IFF_PNG);
651 pixDisplay(pixt, 500, 100);
674 static const char *sel_4_1 =
" x"
677 static const char *sel_4_2 =
" x"
680 static const char *sel_4_3 =
" o "
683 static const char *sel_4_4 =
" o "
686 static const char *sel_4_5 =
" ox"
689 static const char *sel_4_6 =
" o "
692 static const char *sel_4_7 =
" xx"
695 static const char *sel_4_8 =
" x"
698 static const char *sel_4_9 =
"o x"
703 static const char *sel_8_1 =
" x "
706 static const char *sel_8_2 =
" x "
709 static const char *sel_8_3 =
"o "
712 static const char *sel_8_4 =
"o "
715 static const char *sel_8_5 =
"o x"
718 static const char *sel_8_6 =
"o "
721 static const char *sel_8_7 =
" x "
724 static const char *sel_8_8 =
" x "
727 static const char *sel_8_9 =
"ox "
732 static const char *sel_48_1 =
" xx"
735 static const char *sel_48_2 =
"o x"
872 if (size < 3 || linewidth > size)
873 return (
SEL *)ERROR_PTR(
"invalid input", __func__, NULL);
l_ok pixRenderLine(PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op)
pixRenderLine()
PTA * generatePtaLineFromPt(l_int32 x, l_int32 y, l_float64 length, l_float64 radang)
generatePtaLineFromPt()
l_ok pixRenderPta(PIX *pix, PTA *pta, l_int32 op)
pixRenderPta()
l_ok selectComposableSizes(l_int32 size, l_int32 *pfactor1, l_int32 *pfactor2)
selectComposableSizes()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok pixSetPixel(PIX *pix, l_int32 x, l_int32 y, l_uint32 val)
pixSetPixel()
l_ok pixSetAll(PIX *pix)
pixSetAll()
l_ok pixPaintThroughMask(PIX *pixd, PIX *pixm, l_int32 x, l_int32 y, l_uint32 val)
pixPaintThroughMask()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
void pixaDestroy(PIXA **ppixa)
pixaDestroy()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_ok pixaGetPixDimensions(PIXA *pixa, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixaGetPixDimensions()
PIX * pixaDisplayTiledAndScaled(PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
pixaDisplayTiledAndScaled()
void ptaDestroy(PTA **ppta)
ptaDestroy()
l_ok ptaJoin(PTA *ptad, PTA *ptas, l_int32 istart, l_int32 iend)
ptaJoin()
PIX * pixScaleBySampling(PIX *pixs, l_float32 scalex, l_float32 scaley)
pixScaleBySampling()
SEL * selCreateFromPix(PIX *pix, l_int32 cy, l_int32 cx, const char *name)
selCreateFromPix()
l_ok selaWriteStream(FILE *fp, SELA *sela)
selaWriteStream()
SEL * selCreateFromString(const char *text, l_int32 h, l_int32 w, const char *name)
selCreateFromString()
l_ok selSetOrigin(SEL *sel, l_int32 cy, l_int32 cx)
selSetOrigin()
SELA * selaCreate(l_int32 n)
selaCreate()
l_ok selaAddSel(SELA *sela, SEL *sel, const char *selname, l_int32 copyflag)
selaAddSel()
l_ok selSetElement(SEL *sel, l_int32 row, l_int32 col, l_int32 type)
selSetElement()
PIX * selaDisplayInPix(SELA *sela, l_int32 size, l_int32 gthick, l_int32 spacing, l_int32 ncols)
selaDisplayInPix()
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()
SEL * selCreateFromColorPix(PIX *pixs, const char *selname)
SELA * sela8ccThin(SELA *sela)
sela8ccThin()
SELA * selaAddHitMiss(SELA *sela)
selaAddHitMiss()
SELA * selaAddBasic(SELA *sela)
selaAddBasic()
SELA * sela4and8ccThin(SELA *sela)
sela4and8ccThin()
SELA * selaAddDwaCombs(SELA *sela)
selaAddDwaCombs()
SELA * selaAddTJunctions(SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag)
selaAddTJunctions()
SELA * sela4ccThin(SELA *sela)
sela4ccThin()
SELA * selaAddDwaLinear(SELA *sela)
selaAddDwaLinear()
SEL * selMakePlusSign(l_int32 size, l_int32 linewidth)
selMakePlusSign()
SELA * selaAddCrossJunctions(SELA *sela, l_float32 hlsize, l_float32 mdist, l_int32 norient, l_int32 debugflag)
selaAddCrossJunctions()
l_int32 lept_mkdir(const char *subdir)
lept_mkdir()