-----------------------------------------------------------------* * Display of matched patterns * *-----------------------------------------------------------------*/ ! * \brief pixDisplayMatchedPattern() * * \param[in] pixs input image, 1 bpp * \param[in] pixp pattern to be removed from image, 1 bpp * \param[in] pixe image after erosion by Se
| 786 | * </pre> |
| 787 | */ |
| 788 | PIX * |
| 789 | pixDisplayMatchedPattern(PIX *pixs, |
| 790 | PIX *pixp, |
| 791 | PIX *pixe, |
| 792 | l_int32 x0, |
| 793 | l_int32 y0, |
| 794 | l_uint32 color, |
| 795 | l_float32 scale, |
| 796 | l_int32 nlevels) |
| 797 | { |
| 798 | l_int32 i, nc, xb, yb, x, y, xi, yi, rval, gval, bval; |
| 799 | BOXA *boxa; |
| 800 | PIX *pixd, *pixt, *pixps; |
| 801 | PIXA *pixa; |
| 802 | PTA *pta; |
| 803 | PIXCMAP *cmap; |
| 804 | |
| 805 | PROCNAME("pixDisplayMatchedPattern"); |
| 806 | |
| 807 | if (!pixs) |
| 808 | return (PIX *)ERROR_PTR("pixs not defined", procName, NULL); |
| 809 | if (!pixp) |
| 810 | return (PIX *)ERROR_PTR("pixp not defined", procName, NULL); |
| 811 | if (!pixe) |
| 812 | return (PIX *)ERROR_PTR("pixe not defined", procName, NULL); |
| 813 | if (pixGetDepth(pixs) != 1 || pixGetDepth(pixp) != 1 || |
| 814 | pixGetDepth(pixe) != 1) |
| 815 | return (PIX *)ERROR_PTR("all input pix not 1 bpp", procName, NULL); |
| 816 | if (scale > 1.0 || scale <= 0.0) { |
| 817 | L_WARNING("scale > 1.0 or < 0.0; setting to 1.0\n", procName); |
| 818 | scale = 1.0; |
| 819 | } |
| 820 | |
| 821 | /* Find the connected components and their centroids */ |
| 822 | boxa = pixConnComp(pixe, &pixa, 8); |
| 823 | if ((nc = boxaGetCount(boxa)) == 0) { |
| 824 | L_WARNING("no matched patterns\n", procName); |
| 825 | boxaDestroy(&boxa); |
| 826 | pixaDestroy(&pixa); |
| 827 | return 0; |
| 828 | } |
| 829 | pta = pixaCentroids(pixa); |
| 830 | |
| 831 | extractRGBValues(color, &rval, &gval, &bval); |
| 832 | if (scale == 1.0) { /* output 4 bpp at full resolution */ |
| 833 | pixd = pixConvert1To4(NULL, pixs, 0, 1); |
| 834 | cmap = pixcmapCreate(4); |
| 835 | pixcmapAddColor(cmap, 255, 255, 255); |
| 836 | pixcmapAddColor(cmap, 0, 0, 0); |
| 837 | pixSetColormap(pixd, cmap); |
| 838 | |
| 839 | /* Paint through pixp for each match location. The centroid of each |
| 840 | * component in pixe is located at: |
| 841 | * (box->x + x, box->y + y) |
| 842 | * and the 'center' of the pattern used in making pixe is located at |
| 843 | * (x0, y0) |
| 844 | * relative to the UL corner of the pattern. The center of the |
| 845 | * pattern is placed at the center of the component. */ |
nothing calls this directly
no test coverage detected