35 #include "allheaders.h"
37 PIX *pixMorphDwa_1(
PIX *pixd,
PIX *pixs, l_int32 operation,
char *selname);
38 PIX *pixFMorphopGen_1(
PIX *pixd,
PIX *pixs, l_int32 operation,
char *selname);
39 l_int32 fmorphopgen_low_1(l_uint32 *datad, l_int32 w,
40 l_int32 h, l_int32 wpld,
41 l_uint32 *datas, l_int32 wpls,
44 static l_int32 NUM_SELS_GENERATED = 58;
45 static char SEL_NAMES[][80] = {
125 pixMorphDwa_1(
PIX *pixd,
130 l_int32 bordercolor, bordersize;
131 PIX *pixt1, *pixt2, *pixt3;
134 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
135 if (pixGetDepth(pixs) != 1)
136 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, pixd);
141 if (bordercolor == 0 && operation == L_MORPH_CLOSE)
145 pixt2 = pixFMorphopGen_1(NULL, pixt1, operation, selname);
183 pixFMorphopGen_1(
PIX *pixd,
188 l_int32 i, index, found, w, h, wpls, wpld, bordercolor, erodeop, borderop;
189 l_uint32 *datad, *datas, *datat;
193 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, pixd);
194 if (pixGetDepth(pixs) != 1)
195 return (
PIX *)ERROR_PTR(
"pixs must be 1 bpp", __func__, pixd);
199 if (bordercolor == 1)
205 for (i = 0; i < NUM_SELS_GENERATED; i++) {
206 if (strcmp(selname, SEL_NAMES[i]) == 0) {
213 return (
PIX *)ERROR_PTR(
"sel index not found", __func__, pixd);
217 return (
PIX *)ERROR_PTR(
"pixd not made", __func__, NULL);
221 wpls = pixGetWpl(pixs);
222 wpld = pixGetWpl(pixd);
228 w = pixGetWidth(pixs) - 64;
229 h = pixGetHeight(pixs) - 64;
233 if (operation == L_MORPH_DILATE || operation == L_MORPH_ERODE) {
235 if (operation == L_MORPH_ERODE) {
240 if ((pixt =
pixCopy(NULL, pixs)) == NULL)
241 return (
PIX *)ERROR_PTR(
"pixt not made", __func__, pixd);
244 fmorphopgen_low_1(datad, w, h, wpld, datat, wpls, index);
249 fmorphopgen_low_1(datad, w, h, wpld, datas, wpls, index);
254 return (
PIX *)ERROR_PTR(
"pixt not made", __func__, pixd);
256 if (operation == L_MORPH_OPEN) {
258 fmorphopgen_low_1(datat, w, h, wpls, datas, wpls, index+1);
260 fmorphopgen_low_1(datad, w, h, wpld, datat, wpls, index);
264 fmorphopgen_low_1(datat, w, h, wpls, datas, wpls, index);
266 fmorphopgen_low_1(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()