57 #include <config_auto.h>
60 #include "allheaders.h"
88 return ERROR_INT(
"&length not defined", __func__, 1);
91 return ERROR_INT(
"pixs not defined", __func__, 1);
97 if (!tab8) LEPT_FREE(tab);
131 l_int32 i, n, count, length, first, last;
133 l_float32 width1, width2, ratio, extra;
139 return ERROR_INT(
"&width not defined", __func__, 1);
142 return ERROR_INT(
"pixs not defined", __func__, 1);
153 width1 = (l_float32)count / (l_float32)length;
168 for (i = n - 1; i > 0; i--) {
169 ratio = fa[i] / fa[1];
170 if (ratio > thresh)
break;
176 extra = (i < n - 1) ? fa[i + 1] / fa[1] : 0;
177 width2 = 2.0 * (i - 1.0 + ratio + extra);
178 lept_stderr(
"width1 = %5.2f, width2 = %5.2f\n", width1, width2);
181 *pwidth = (width1 + width2) / 2.0;
183 if (!tab8) LEPT_FREE(tab);
213 l_int32 i, n, same, maxd;
220 return (
NUMA *)ERROR_PTR(
"pixa not defined", __func__, NULL);
223 return (
NUMA *)ERROR_PTR(
"pix not all 1 bpp", __func__, NULL);
229 for (i = 0; i < n; i++) {
236 if (!tab8) LEPT_FREE(tab);
255 l_int32 i, n, same, maxd;
262 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
264 return (
PIXA *)ERROR_PTR(
"target width < 1", __func__, NULL);
267 return (
PIXA *)ERROR_PTR(
"pix not all 1 bpp", __func__, NULL);
272 for (i = 0; i < n; i++) {
301 if (!pixs || (pixGetDepth(pixs) != 1))
302 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
304 return (
PIX *)ERROR_PTR(
"target width < 1", __func__, NULL);
307 if (diff == 0)
return pixCopy(NULL, pixs);
309 size = L_ABS(diff) + 1;
311 snprintf(buf,
sizeof(buf),
"e%d.%d", size, size);
313 snprintf(buf,
sizeof(buf),
"d%d.%d", size, size);
342 l_int32 connectivity)
344 l_int32 i, n, maxd, same;
349 return (
PIXA *)ERROR_PTR(
"pixas not defined", __func__, NULL);
350 if (width < 1 || width > 100)
351 return (
PIXA *)ERROR_PTR(
"width not in [1 ... 100]", __func__, NULL);
352 if (connectivity != 4 && connectivity != 8)
353 return (
PIXA *)ERROR_PTR(
"connectivity not 4 or 8", __func__, NULL);
356 return (
PIXA *)ERROR_PTR(
"pix are not all 1 bpp", __func__, NULL);
360 for (i = 0; i < n; i++) {
392 l_int32 connectivity)
396 PIX *pix1, *pix2, *pixd;
398 if (!pixs || (pixGetDepth(pixs) != 1))
399 return (
PIX *)ERROR_PTR(
"pixs undefined or not 1 bpp", __func__, NULL);
400 if (width < 1 || width > 100)
401 return (
PIX *)ERROR_PTR(
"width not in [1 ... 100]", __func__, NULL);
402 if (connectivity != 4 && connectivity != 8)
403 return (
PIX *)ERROR_PTR(
"connectivity not 4 or 8", __func__, NULL);
405 if (!thinfirst && width == 1)
420 snprintf(buf,
sizeof(buf),
"D%d.%d", width, width);
422 pixCopyText(pixd, pixs);
PIX * pixThinConnected(PIX *pixs, l_int32 type, l_int32 connectivity, l_int32 maxiters)
pixThinConnected()
PIX * pixExtractBoundary(PIX *pixs, l_int32 type)
pixExtractBoundary()
PIX * pixMorphSequence(PIX *pixs, const char *sequence, l_int32 dispsep)
pixMorphSequence()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
l_ok numaGetFValue(NUMA *na, l_int32 index, l_float32 *pval)
numaGetFValue()
l_ok numaWriteStderr(NUMA *na)
numaWriteStderr()
NUMA * numaCreate(l_int32 n)
numaCreate()
void numaDestroy(NUMA **pna)
numaDestroy()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_float32 * numaGetFArray(NUMA *na, l_int32 copyflag)
numaGetFArray()
NUMA * numaClipToInterval(NUMA *nas, l_int32 first, l_int32 last)
numaClipToInterval()
l_ok numaGetNonzeroRange(NUMA *na, l_float32 eps, l_int32 *pfirst, l_int32 *plast)
numaGetNonzeroRange()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixClone(PIX *pixs)
pixClone()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
l_ok pixCountPixels(PIX *pixs, l_int32 *pcount, l_int32 *tab8)
pixCountPixels()
l_int32 * makePixelSumTab8(void)
makePixelSumTab8()
NUMA * pixGetGrayHistogram(PIX *pixs, l_int32 factor)
pixGetGrayHistogram()
l_ok pixaAddPix(PIXA *pixa, PIX *pix, l_int32 copyflag)
pixaAddPix()
l_ok pixaVerifyDepth(PIXA *pixa, l_int32 *psame, l_int32 *pmaxd)
pixaVerifyDepth()
PIXA * pixaCreate(l_int32 n)
pixaCreate()
l_int32 pixaGetCount(PIXA *pixa)
pixaGetCount()
PIX * pixaGetPix(PIXA *pixa, l_int32 index, l_int32 accesstype)
pixaGetPix()
PIX * pixDistanceFunction(PIX *pixs, l_int32 connectivity, l_int32 outdepth, l_int32 boundcond)
pixDistanceFunction()
PIX * pixSetStrokeWidth(PIX *pixs, l_int32 width, l_int32 thinfirst, l_int32 connectivity)
pixSetStrokeWidth()
NUMA * pixaFindStrokeWidth(PIXA *pixa, l_float32 thresh, l_int32 *tab8, l_int32 debug)
pixaFindStrokeWidth()
l_ok pixFindStrokeLength(PIX *pixs, l_int32 *tab8, l_int32 *plength)
pixFindStrokeLength()
PIXA * pixaSetStrokeWidth(PIXA *pixas, l_int32 width, l_int32 thinfirst, l_int32 connectivity)
pixaSetStrokeWidth()
l_ok pixFindStrokeWidth(PIX *pixs, l_float32 thresh, l_int32 *tab8, l_float32 *pwidth, NUMA **pnahisto)
pixFindStrokeWidth()
PIXA * pixaModifyStrokeWidth(PIXA *pixas, l_float32 targetw)
pixaModifyStrokeWidth()
PIX * pixModifyStrokeWidth(PIX *pixs, l_float32 width, l_float32 targetw)
pixModifyStrokeWidth()
void lept_stderr(const char *fmt,...)
lept_stderr()
l_int32 lept_roundftoi(l_float32 fval)
lept_roundftoi()