MCPcopy Create free account
hub / github.com/creatale/node-dv / pixDisplayMatchedPattern

Function pixDisplayMatchedPattern

deps/leptonica/src/morphapp.c:788–872  ·  view source on GitHub ↗

-----------------------------------------------------------------* * 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

Source from the content-addressed store, hash-verified

786 * </pre>
787 */
788PIX *
789pixDisplayMatchedPattern(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{
798l_int32 i, nc, xb, yb, x, y, xi, yi, rval, gval, bval;
799BOXA *boxa;
800PIX *pixd, *pixt, *pixps;
801PIXA *pixa;
802PTA *pta;
803PIXCMAP *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. */

Callers

nothing calls this directly

Calls 15

pixGetDepthFunction · 0.85
pixConnCompFunction · 0.85
boxaGetCountFunction · 0.85
boxaDestroyFunction · 0.85
pixaDestroyFunction · 0.85
pixaCentroidsFunction · 0.85
extractRGBValuesFunction · 0.85
pixConvert1To4Function · 0.85
pixcmapCreateFunction · 0.85
pixcmapAddColorFunction · 0.85
pixSetColormapFunction · 0.85
ptaGetIPtFunction · 0.85

Tested by

no test coverage detected