FindParent() public method

public FindParent ( Shape shape, Fill fill, CardColor color ) : ContourNode
shape Shape
fill Fill
color CardColor
return ContourNode
Esempio n. 1
0
 private Image<Bgr, Byte> RemoveCardColor(ContourNode node, Image<Bgr, Byte> removeFrom)
 {
     ContourNode parentCard = node.FindParent(Shape.Card, null, null);
     if (parentCard != null)
     {
         //Image<Bgr, Byte> eroded = removeFrom.Erode(1);
         //Image<Bgr, Byte> thresholded = eroded.ThresholdBinary(parentCard.averageBgr, new Bgr(255,255,255));
         //return thresholded;
         Image<Gray, Byte> gray = removeFrom.Convert<Gray, Byte>();
         Image<Bgr, Byte> multiplier = new Image<Bgr, byte>(new Image<Gray, byte>[] { gray, gray, gray });
         Image<Bgr, Byte> mul = removeFrom.Mul(multiplier, 0.015);
         Image<Bgr, Byte> threshed = mul.ThresholdToZeroInv(new Bgr(254, 254, 254));
         Image<Gray, Byte> mask = threshed.Convert<Gray, Byte>();
         Image<Bgr, Byte> result = mul.And(new Bgr(255, 255, 255), mask);
         result = result.Mul(multiplier, 0.005);
         return result;
     }
     else
     {
         return removeFrom;
     }
 }
Esempio n. 2
0
        private static void FilterNode(ContourNode node)
        {
            ContourNode card = node.FindParent(Shape.Card, null, null);

            int minArea = 1000;
            if (card != null)
            {
                minArea = (int)card.Contour.Area / 20;
            }

            for (int i = 0; i < node.Children.Count; i++)
            {
                ContourNode child = node.Children[i];
                if (child.Contour.Area < minArea)
                {
                    node.Children.Remove(child);
                }
            }
        }