----------------------------------------------------------------------* * Making a kernel from a Pix * *----------------------------------------------------------------------*/ ! * \brief kernelCreateFromPix() * * \param[in] pix * \param[in] cy, cx origin of kernel * \return kernel, or NULL on error * * * Notes: * (1) The ori
| 862 | * </pre> |
| 863 | */ |
| 864 | L_KERNEL * |
| 865 | kernelCreateFromPix(PIX *pix, |
| 866 | l_int32 cy, |
| 867 | l_int32 cx) |
| 868 | { |
| 869 | l_int32 i, j, w, h, d; |
| 870 | l_uint32 val; |
| 871 | L_KERNEL *kel; |
| 872 | |
| 873 | PROCNAME("kernelCreateFromPix"); |
| 874 | |
| 875 | if (!pix) |
| 876 | return (L_KERNEL *)ERROR_PTR("pix not defined", procName, NULL); |
| 877 | pixGetDimensions(pix, &w, &h, &d); |
| 878 | if (d != 8) |
| 879 | return (L_KERNEL *)ERROR_PTR("pix not 8 bpp", procName, NULL); |
| 880 | if (cy < 0 || cx < 0 || cy >= h || cx >= w) |
| 881 | return (L_KERNEL *)ERROR_PTR("(cy, cx) invalid", procName, NULL); |
| 882 | |
| 883 | kel = kernelCreate(h, w); |
| 884 | kernelSetOrigin(kel, cy, cx); |
| 885 | for (i = 0; i < h; i++) { |
| 886 | for (j = 0; j < w; j++) { |
| 887 | pixGetPixel(pix, j, i, &val); |
| 888 | kernelSetElement(kel, i, j, (l_float32)val); |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | return kel; |
| 893 | } |
| 894 | |
| 895 | |
| 896 | /*----------------------------------------------------------------------* |
nothing calls this directly
no test coverage detected