! * \brief pixBlockconvGrayTile() * * \param[in] pixs 8 bpp gray * \param[in] pixacc 32 bpp accum pix * \param[in] wc, hc half width/height of convolution kernel * \return pixd, or NULL on error * * * Notes: * (1) The full width and height of the convolution kernel * are (2 * wc + 1) and (2 * hc + 1) * (2) Assumes that the input pixs is padded wit
| 850 | * </pre> |
| 851 | */ |
| 852 | PIX * |
| 853 | pixBlockconvGrayTile(PIX *pixs, |
| 854 | PIX *pixacc, |
| 855 | l_int32 wc, |
| 856 | l_int32 hc) |
| 857 | { |
| 858 | l_int32 w, h, d, wd, hd, i, j, imin, imax, jmin, jmax, wplt, wpld; |
| 859 | l_float32 norm; |
| 860 | l_uint32 val; |
| 861 | l_uint32 *datat, *datad, *lined, *linemint, *linemaxt; |
| 862 | PIX *pixt, *pixd; |
| 863 | |
| 864 | PROCNAME("pixBlockconvGrayTile"); |
| 865 | |
| 866 | if (!pixs) |
| 867 | return (PIX *)ERROR_PTR("pix not defined", procName, NULL); |
| 868 | pixGetDimensions(pixs, &w, &h, &d); |
| 869 | if (d != 8) |
| 870 | return (PIX *)ERROR_PTR("pixs not 8 bpp", procName, NULL); |
| 871 | if (wc < 0) wc = 0; |
| 872 | if (hc < 0) hc = 0; |
| 873 | if (w < 2 * wc + 3 || h < 2 * hc + 3) { |
| 874 | wc = L_MAX(0, L_MIN(wc, (w - 3) / 2)); |
| 875 | hc = L_MAX(0, L_MIN(hc, (h - 3) / 2)); |
| 876 | L_WARNING("kernel too large; reducing!\n", procName); |
| 877 | L_INFO("wc = %d, hc = %d\n", procName, wc, hc); |
| 878 | } |
| 879 | if (wc == 0 && hc == 0) |
| 880 | return pixCopy(NULL, pixs); |
| 881 | wd = w - 2 * wc; |
| 882 | hd = h - 2 * hc; |
| 883 | |
| 884 | if (pixacc) { |
| 885 | if (pixGetDepth(pixacc) == 32) { |
| 886 | pixt = pixClone(pixacc); |
| 887 | } else { |
| 888 | L_WARNING("pixacc not 32 bpp; making new one\n", procName); |
| 889 | if ((pixt = pixBlockconvAccum(pixs)) == NULL) |
| 890 | return (PIX *)ERROR_PTR("pixt not made", procName, NULL); |
| 891 | } |
| 892 | } else { |
| 893 | if ((pixt = pixBlockconvAccum(pixs)) == NULL) |
| 894 | return (PIX *)ERROR_PTR("pixt not made", procName, NULL); |
| 895 | } |
| 896 | |
| 897 | if ((pixd = pixCreateTemplate(pixs)) == NULL) { |
| 898 | pixDestroy(&pixt); |
| 899 | return (PIX *)ERROR_PTR("pixd not made", procName, NULL); |
| 900 | } |
| 901 | datat = pixGetData(pixt); |
| 902 | wplt = pixGetWpl(pixt); |
| 903 | datad = pixGetData(pixd); |
| 904 | wpld = pixGetWpl(pixd); |
| 905 | norm = 1. / (l_float32)((2 * wc + 1) * (2 * hc + 1)); |
| 906 | |
| 907 | /* Do the convolution over the subregion of size (wd - 2, hd - 2), |
| 908 | * which exactly corresponds to the size of the subregion that |
| 909 | * will be extracted by pixTilingPaintTile(). Note that the |
no test coverage detected