35 #include <config_auto.h>
39 #include "allheaders.h"
41 PIX *pixMorphDwa_2(
PIX *pixd,
PIX *pixs, l_int32 operation,
char *selname);
42 PIX *pixFMorphopGen_2(
PIX *pixd,
PIX *pixs, l_int32 operation,
char *selname);
43 l_int32 fmorphopgen_low_2(l_uint32 *datad, l_int32 w,
44 l_int32 h, l_int32 wpld,
45 l_uint32 *datas, l_int32 wpls,
48 static l_int32 NUM_SELS_GENERATED = 76;
49 static char SEL_NAMES[][80] = {
147 pixMorphDwa_2(
PIX *pixd,
152 l_int32 bordercolor, bordersize;
153 PIX *pixt1, *pixt2, *pixt3;
156 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
157 if (pixGetDepth(pixs) != 1)
158 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, pixd);
163 if (bordercolor == 0 && operation == L_MORPH_CLOSE)
167 pixt2 = pixFMorphopGen_2(NULL, pixt1, operation, selname);
205 pixFMorphopGen_2(
PIX *pixd,
210 l_int32 i, index, found, w, h, wpls, wpld, bordercolor, erodeop, borderop;
211 l_uint32 *datad, *datas, *datat;
215 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
216 if (pixGetDepth(pixs) != 1)
217 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, pixd);
221 if (bordercolor == 1)
227 for (i = 0; i < NUM_SELS_GENERATED; i++) {
228 if (strcmp(selname, SEL_NAMES[i]) == 0) {
235 return (
PIX *)ERROR_PTR(
"sel index not found", __func__, pixd);
239 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
243 wpls = pixGetWpl(pixs);
244 wpld = pixGetWpl(pixd);
250 w = pixGetWidth(pixs) - 64;
251 h = pixGetHeight(pixs) - 64;
255 if (operation == L_MORPH_DILATE || operation == L_MORPH_ERODE) {
257 if (operation == L_MORPH_ERODE) {
262 if ((pixt =
pixCopy(NULL, pixs)) == NULL)
263 return (
PIX *)ERROR_PTR(
"pixt not made", __func__, pixd);
266 fmorphopgen_low_2(datad, w, h, wpld, datat, wpls, index);
271 fmorphopgen_low_2(datad, w, h, wpld, datas, wpls, index);
276 return (
PIX *)ERROR_PTR(
"pixt not made", __func__, pixd);
278 if (operation == L_MORPH_OPEN) {
280 fmorphopgen_low_2(datat, w, h, wpls, datas, wpls, index+1);
282 fmorphopgen_low_2(datad, w, h, wpld, datat, wpls, index);
286 fmorphopgen_low_2(datat, w, h, wpls, datas, wpls, index);
288 fmorphopgen_low_2(datad, w, h, wpld, datat, wpls, index+1);
l_uint32 getMorphBorderPixelColor(l_int32 type, l_int32 depth)
getMorphBorderPixelColor()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
l_ok pixResizeImageData(PIX *pixd, const PIX *pixs)
pixResizeImageData()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixCopy(PIX *pixd, const PIX *pixs)
pixCopy()
PIX * pixCreateTemplate(const PIX *pixs)
pixCreateTemplate()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
PIX * pixRemoveBorder(PIX *pixs, l_int32 npix)
pixRemoveBorder()
l_ok pixSetOrClearBorder(PIX *pixs, l_int32 left, l_int32 right, l_int32 top, l_int32 bot, l_int32 op)
pixSetOrClearBorder()