/*====================================================================*
- Copyright (C) 2001 Leptonica. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*====================================================================*/
/*!
* Top-level fast binary morphology with auto-generated sels
*
--- * PIX *pixMorphDwa_*()
--- * PIX *pixFMorphopGen_*()
*/
#include <string.h>
#include "allheaders.h"
--- This file is: morphtemplate1.txt
---
--- We need to include these prototypes:
--- PIX *pixMorphDwa_*(PIX *pixd, PIX *pixs, l_int32 operation,
--- char *selname);
--- PIX *pixFMorphopGen_*(PIX *pixd, PIX *pixs, l_int32 operation,
--- char *selname);
--- l_int32 fmorphopgen_low_*(l_uint32 *datad, l_int32 w, l_int32 h,
--- l_int32 wpld, l_uint32 *datas,
--- l_int32 wpls, l_int32 index);
---
--- We need to input two static globals here:
--- static l_int32 NUM_SELS_GENERATED = <some number>;
--- static char SEL_NAMES[][80] = {"<string1>", "<string2>", ...};
/*!
--- * \brief pixMorphDwa_*()
*
* \param[in] pixd usual 3 choices: null, == pixs, != pixs
* \param[in] pixs 1 bpp
* \param[in] operation L_MORPH_DILATE, L_MORPH_ERODE,
* L_MORPH_OPEN, L_MORPH_CLOSE
* \param[in] sel name
* \return pixd
*
* <pre>
* Notes:
* (1) This simply adds a border, calls the appropriate
* pixFMorphopGen_*(), and removes the border.
* See the notes for that function.
* (2) The size of the border depends on the operation
* and the boundary conditions.
* </pre>
*/
PIX *
--- pixMorphDwa_*(PIX *pixd,
PIX *pixs,
l_int32 operation,
char *selname)
{
l_int32 bordercolor, bordersize;
PIX *pixt1, *pixt2, *pixt3;
--- PROCNAME("pixMorpDwa_*");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, pixd);
if (pixGetDepth(pixs) != 1)
return (PIX *)ERROR_PTR("pixs must be 1 bpp", procName, pixd);
/* Set the border size */
bordercolor = getMorphBorderPixelColor(L_MORPH_ERODE, 1);
bordersize = 32;
if (bordercolor == 0 && operation == L_MORPH_CLOSE)
bordersize += 32;
pixt1 = pixAddBorder(pixs, bordersize, 0);
--- pixt2 = pixFMorphopGen_*(NULL, pixt1, operation, selname);
pixt3 = pixRemoveBorder(pixt2, bordersize);
pixDestroy(&pixt1);
pixDestroy(&pixt2);
if (!pixd)
return pixt3;
pixCopy(pixd, pixt3);
pixDestroy(&pixt3);
return pixd;
}
/*!
--- * \brief pixFMorphopGen_*()
*
* \param[in] pixd usual 3 choices: null, == pixs, != pixs
* \param[in] pixs 1 bpp
* \param[in] operation L_MORPH_DILATE, L_MORPH_ERODE,
* L_MORPH_OPEN, L_MORPH_CLOSE
* \param[in] sel name
* \return pixd
*
* <pre>
* Notes:
* (1) This is a dwa operation, and the Sels must be limited in
* size to not more than 31 pixels about the origin.
* (2) A border of appropriate size (32 pixels, or 64 pixels
* for safe closing with asymmetric b.c.) must be added before
* this function is called.
* (3) This handles all required setting of the border pixels
* before erosion and dilation.
* (4) The closing operation is safe; no pixels can be removed
* near the boundary.
* </pre>
*/
PIX *
--- pixFMorphopGen_*(PIX *pixd,
PIX *pixs,
l_int32 operation,
char *selname)
{
l_int32 i, index, found, w, h, wpls, wpld, bordercolor, erodeop, borderop;
l_uint32 *datad, *datas, *datat;
PIX *pixt;
--- PROCNAME("pixFMorphopGen_*");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, pixd);
if (pixGetDepth(pixs) != 1)
return (PIX *)ERROR_PTR("pixs must be 1 bpp", procName, pixd);
/* Get boundary colors to use */
bordercolor = getMorphBorderPixelColor(L_MORPH_ERODE, 1);
if (bordercolor == 1)
erodeop = PIX_SET;
else
erodeop = PIX_CLR;
found = FALSE;
for (i = 0; i < NUM_SELS_GENERATED; i++) {
if (strcmp(selname, SEL_NAMES[i]) == 0) {
found = TRUE;
index = 2 * i;
break;
}
}
if (found == FALSE)
return (PIX *)ERROR_PTR("sel index not found", procName, pixd);
if (!pixd) {
if ((pixd = pixCreateTemplate(pixs)) == NULL)
return (PIX *)ERROR_PTR("pixd not made", procName, NULL);
}
else /* for in-place or pre-allocated */
pixResizeImageData(pixd, pixs);
wpls = pixGetWpl(pixs);
wpld = pixGetWpl(pixd);
/* The images must be surrounded, in advance, with a border of
* size 32 pixels (or 64, for closing), that we'll read from.
* Fabricate a "proper" image as the subimage within the 32
* pixel border, having the following parameters: */
w = pixGetWidth(pixs) - 64;
h = pixGetHeight(pixs) - 64;
datas = pixGetData(pixs) + 32 * wpls + 1;
datad = pixGetData(pixd) + 32 * wpld + 1;
if (operation == L_MORPH_DILATE || operation == L_MORPH_ERODE) {
borderop = PIX_CLR;
if (operation == L_MORPH_ERODE) {
borderop = erodeop;
index++;
}
if (pixd == pixs) { /* in-place; generate a temp image */
if ((pixt = pixCopy(NULL, pixs)) == NULL)
return (PIX *)ERROR_PTR("pixt not made", procName, pixd);
datat = pixGetData(pixt) + 32 * wpls + 1;
pixSetOrClearBorder(pixt, 32, 32, 32, 32, borderop);
--- fmorphopgen_low_*(datad, w, h, wpld, datat, wpls, index);
pixDestroy(&pixt);
}
else { /* not in-place */
pixSetOrClearBorder(pixs, 32, 32, 32, 32, borderop);
--- fmorphopgen_low_*(datad, w, h, wpld, datas, wpls, index);
}
}
else { /* opening or closing; generate a temp image */
if ((pixt = pixCreateTemplate(pixs)) == NULL)
return (PIX *)ERROR_PTR("pixt not made", procName, pixd);
datat = pixGetData(pixt) + 32 * wpls + 1;
if (operation == L_MORPH_OPEN) {
pixSetOrClearBorder(pixs, 32, 32, 32, 32, erodeop);
--- fmorphopgen_low_*(datat, w, h, wpls, datas, wpls, index + 1);
pixSetOrClearBorder(pixt, 32, 32, 32, 32, PIX_CLR);
--- fmorphopgen_low_*(datad, w, h, wpld, datat, wpls, index);
}
else { /* closing */
pi
没有合适的资源?快使用搜索试试~ 我知道了~
OCR工程可直接使用,,,包含
共479个文件
c:179个
h:93个
dll:72个
需积分: 9 0 下载量 25 浏览量
2022-10-20
19:31:11
上传
评论
收藏 144.31MB RAR 举报
温馨提示
OCR工程可直接使用,,,包含
资源详情
资源评论
资源推荐
收起资源包目录
OCR工程可直接使用,,,包含 (479个子文件)
Makefile.am 5KB
fmorphgenlow.1.c 199KB
colorquant1.c 160KB
pixconv.c 141KB
scale1.c 139KB
dwacomblow.2.c 135KB
seedfill.c 134KB
compare.c 131KB
pix3.c 123KB
pix4.c 119KB
adaptmap.c 110KB
numafunc2.c 108KB
numafunc1.c 108KB
pix2.c 107KB
utils2.c 105KB
grayquant.c 105KB
pix5.c 102KB
pixafunc2.c 97KB
pixafunc1.c 97KB
tiffio.c 97KB
jbclass.c 93KB
convolve.c 92KB
pageseg.c 90KB
blend.c 88KB
pixabasic.c 87KB
pdfio2.c 87KB
roplow.c 87KB
graphics.c 87KB
recogtrain.c 86KB
ccbord.c 83KB
enhance.c 83KB
scale2.c 83KB
pdfio1.c 83KB
boxfunc1.c 82KB
pngio.c 81KB
colorcontent.c 79KB
ptafunc1.c 77KB
colorspace.c 76KB
pixcomp.c 75KB
psio2.c 74KB
dewarp2.c 73KB
fpix2.c 72KB
sel1.c 70KB
colormap.c 68KB
boxfunc5.c 68KB
recogident.c 67KB
morph.c 66KB
boxfunc2.c 64KB
sarray1.c 64KB
colorquant2.c 63KB
morphdwa.c 62KB
boxbasic.c 61KB
dewarp1.c 61KB
bootnumgen4.c 59KB
pix1.c 59KB
affine.c 57KB
morphapp.c 56KB
boxfunc3.c 55KB
pixarith.c 54KB
readbarcode.c 54KB
numabasic.c 53KB
fpix1.c 52KB
warper.c 52KB
readfile.c 51KB
pnmio.c 50KB
dnabasic.c 49KB
skew.c 48KB
binarize.c 47KB
graymorph.c 46KB
jpegio.c 46KB
gplot.c 45KB
boxfunc4.c 43KB
recogbasic.c 42KB
dewarp4.c 42KB
morphseq.c 42KB
rotateam.c 42KB
coloring.c 41KB
psio1.c 41KB
conncomp.c 40KB
ptabasic.c 39KB
textops.c 39KB
utils1.c 39KB
recogdid.c 39KB
kernel.c 38KB
classapp.c 37KB
watershed.c 37KB
correlscore.c 37KB
dewarp3.c 37KB
writefile.c 37KB
maze.c 36KB
selgen.c 35KB
jp2kio.c 34KB
parseprotos.c 34KB
fmorphauto.c 33KB
bardecode.c 33KB
flipdetect.c 32KB
bilateral.c 32KB
fhmtauto.c 31KB
projective.c 31KB
colorfill.c 31KB
共 479 条
- 1
- 2
- 3
- 4
- 5
ppppp_dddd
- 粉丝: 259
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0