----------------------------------------------------------------------* * Tiled grayscale or color block convolution * *----------------------------------------------------------------------*/ ! * \brief pixBlockconvTiled() * * \param[in] pix 8 or 32 bpp; or 2, 4 or 8 bpp with colormap * \param[in] wc, hc half width/height of convolution kernel * \param[i
| 724 | * </pre> |
| 725 | */ |
| 726 | PIX * |
| 727 | pixBlockconvTiled(PIX *pix, |
| 728 | l_int32 wc, |
| 729 | l_int32 hc, |
| 730 | l_int32 nx, |
| 731 | l_int32 ny) |
| 732 | { |
| 733 | l_int32 i, j, w, h, d, xrat, yrat; |
| 734 | PIX *pixs, *pixd, *pixc, *pixt; |
| 735 | PIX *pixr, *pixrc, *pixg, *pixgc, *pixb, *pixbc; |
| 736 | PIXTILING *pt; |
| 737 | |
| 738 | PROCNAME("pixBlockconvTiled"); |
| 739 | |
| 740 | if (!pix) |
| 741 | return (PIX *)ERROR_PTR("pix not defined", procName, NULL); |
| 742 | if (wc < 0) wc = 0; |
| 743 | if (hc < 0) hc = 0; |
| 744 | pixGetDimensions(pix, &w, &h, &d); |
| 745 | if (w < 2 * wc + 3 || h < 2 * hc + 3) { |
| 746 | wc = L_MAX(0, L_MIN(wc, (w - 3) / 2)); |
| 747 | hc = L_MAX(0, L_MIN(hc, (h - 3) / 2)); |
| 748 | L_WARNING("kernel too large; reducing!\n", procName); |
| 749 | L_INFO("wc = %d, hc = %d\n", procName, wc, hc); |
| 750 | } |
| 751 | if (wc == 0 && hc == 0) /* no-op */ |
| 752 | return pixCopy(NULL, pix); |
| 753 | if (nx <= 1 && ny <= 1) |
| 754 | return pixBlockconv(pix, wc, hc); |
| 755 | |
| 756 | /* Test to see if the tiles are too small. The required |
| 757 | * condition is that the tile dimensions must be at least |
| 758 | * (wc + 2) x (hc + 2). */ |
| 759 | xrat = w / nx; |
| 760 | yrat = h / ny; |
| 761 | if (xrat < wc + 2) { |
| 762 | nx = w / (wc + 2); |
| 763 | L_WARNING("tile width too small; nx reduced to %d\n", procName, nx); |
| 764 | } |
| 765 | if (yrat < hc + 2) { |
| 766 | ny = h / (hc + 2); |
| 767 | L_WARNING("tile height too small; ny reduced to %d\n", procName, ny); |
| 768 | } |
| 769 | |
| 770 | /* Remove colormap if necessary */ |
| 771 | if ((d == 2 || d == 4 || d == 8) && pixGetColormap(pix)) { |
| 772 | L_WARNING("pix has colormap; removing\n", procName); |
| 773 | pixs = pixRemoveColormap(pix, REMOVE_CMAP_BASED_ON_SRC); |
| 774 | d = pixGetDepth(pixs); |
| 775 | } else { |
| 776 | pixs = pixClone(pix); |
| 777 | } |
| 778 | |
| 779 | if (d != 8 && d != 32) { |
| 780 | pixDestroy(&pixs); |
| 781 | return (PIX *)ERROR_PTR("depth not 8 or 32 bpp", procName, NULL); |
| 782 | } |
| 783 |
nothing calls this directly
no test coverage detected