! * \brief pixIntersectionOfMorphOps() * * \param[in] pixs binary * \param[in] sela * \param[in] type L_MORPH_DILATE, etc. * \return pixd intersection of the specified morphological operation * on pixs for each Sel in the Sela, or NULL on error */
| 552 | * on pixs for each Sel in the Sela, or NULL on error |
| 553 | */ |
| 554 | PIX * |
| 555 | pixIntersectionOfMorphOps(PIX *pixs, |
| 556 | SELA *sela, |
| 557 | l_int32 type) |
| 558 | { |
| 559 | l_int32 n, i; |
| 560 | PIX *pixt, *pixd; |
| 561 | SEL *sel; |
| 562 | |
| 563 | PROCNAME("pixIntersectionOfMorphOps"); |
| 564 | |
| 565 | if (!pixs || pixGetDepth(pixs) != 1) |
| 566 | return (PIX *)ERROR_PTR("pixs undefined or not 1 bpp", procName, NULL); |
| 567 | if (!sela) |
| 568 | return (PIX *)ERROR_PTR("sela not defined", procName, NULL); |
| 569 | n = selaGetCount(sela); |
| 570 | if (n == 0) |
| 571 | return (PIX *)ERROR_PTR("no sels in sela", procName, NULL); |
| 572 | if (type != L_MORPH_DILATE && type != L_MORPH_ERODE && |
| 573 | type != L_MORPH_OPEN && type != L_MORPH_CLOSE && |
| 574 | type != L_MORPH_HMT) |
| 575 | return (PIX *)ERROR_PTR("invalid type", procName, NULL); |
| 576 | |
| 577 | pixd = pixCreateTemplate(pixs); |
| 578 | pixSetAll(pixd); |
| 579 | for (i = 0; i < n; i++) { |
| 580 | sel = selaGetSel(sela, i); |
| 581 | if (type == L_MORPH_DILATE) |
| 582 | pixt = pixDilate(NULL, pixs, sel); |
| 583 | else if (type == L_MORPH_ERODE) |
| 584 | pixt = pixErode(NULL, pixs, sel); |
| 585 | else if (type == L_MORPH_OPEN) |
| 586 | pixt = pixOpen(NULL, pixs, sel); |
| 587 | else if (type == L_MORPH_CLOSE) |
| 588 | pixt = pixClose(NULL, pixs, sel); |
| 589 | else /* type == L_MORPH_HMT */ |
| 590 | pixt = pixHMT(NULL, pixs, sel); |
| 591 | pixAnd(pixd, pixd, pixt); |
| 592 | pixDestroy(&pixt); |
| 593 | } |
| 594 | |
| 595 | return pixd; |
| 596 | } |
| 597 | |
| 598 | |
| 599 |
nothing calls this directly
no test coverage detected