Exemplo n.º 1
0
        public static double CompareShapePercentage(ProbabilisticImage A, ProbabilisticImage B)
        {
            double PointCount = Utility.Utility.GetGreatest(A.SampleCount, B.SampleCount);
            double Amount = 0.0, IncreaseAmount = 1.0 / PointCount;

            for (int i = 0; i < PointCount; i++)
            {
                double RelativeX = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;
                double RelativeY = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;

                Point ACompare = new Point();
                Point BCompare = new Point();

                if (A.IsCircle && B.IsCircle)
                {
                    ACompare = A.GetCircularPoint(RelativeX, RelativeY);
                    BCompare = B.GetCircularPoint(RelativeX, RelativeY);
                }
                else
                {
                    ACompare = A.GetRectangularPoint(RelativeX, RelativeY);
                    BCompare = B.GetRectangularPoint(RelativeX, RelativeY);
                }

                //If neither is a background color, then it must be part of the main picture, and therefore the shape is the same here.
                if ((!ImageUtility.ColorCheck(A.BackgroundColor, A.GetPixel(ACompare))) == (!ImageUtility.ColorCheck(B.BackgroundColor, B.GetPixel(BCompare))))
                {
                    Amount += IncreaseAmount;
                }
            }

            return(Amount);
        }
Exemplo n.º 2
0
        public static double CompareColorPercentage(ProbabilisticImage A, ProbabilisticImage B, bool RoughColorMatch)
        {
            double PointCount = Math.Pow(A.R, 2);
            double Amount = 0.0, IncreaseAmount = 1.0 / PointCount;

            for (int x = -A.R; x < A.R; x++)
            {
                for (int y = -A.R; y < A.R; y++)
                {
                    double RelativeX = (double)x / (double)A.R;
                    double RelativeY = (double)y / (double)A.R;

                    Point ACompare = new Point();
                    Point BCompare = new Point();

                    if (A.IsCircle && B.IsCircle)
                    {
                        ACompare = A.GetCircularPoint(RelativeX, RelativeY);
                        BCompare = B.GetCircularPoint(RelativeX, RelativeY);
                    }
                    else
                    {
                        ACompare = A.GetRectangularPoint(RelativeX, RelativeY);
                        BCompare = B.GetRectangularPoint(RelativeX, RelativeY);
                    }

                    Color APixel = A.GetPixel(ACompare);
                    Color BPixel = B.GetPixel(BCompare);

                    //Console.WriteLine("{0} == {1} = {2}", APixel.ToString(), B.GetPixel(BCompare).ToString(), ImageUtility.ColorCheck(APixel, B.GetPixel(BCompare)));

                    if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) ^ ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                    {
                        continue;
                    }
                    else if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) && ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                    {
                        Amount += IncreaseAmount;
                        continue;
                    }
                    else if (ImageUtility.ColorCheck(APixel, BPixel))
                    {
                        Amount += IncreaseAmount;
                    }
                }
            }

            return(Amount);
        }
Exemplo n.º 3
0
        public static double CompareColorPercentage(ProbabilisticImage A, ProbabilisticImage B, bool RoughColorMatch)
        {
            double PointCount = Utility.Utility.GetGreatest(A.SampleCount, B.SampleCount);
            double Amount = 0.0, IncreaseAmount = 1.0 / PointCount;

            Console.WriteLine($"Sampling {PointCount} pixels.");

            for (int i = 0; i < PointCount; i++)
            {
                double RelativeX = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;
                double RelativeY = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;

                Point ACompare = new Point();
                Point BCompare = new Point();

                if (A.IsCircle && B.IsCircle)
                {
                    ACompare = A.GetCircularPoint(RelativeX, RelativeY);
                    BCompare = B.GetCircularPoint(RelativeX, RelativeY);
                }
                else
                {
                    ACompare = A.GetRectangularPoint(RelativeX, RelativeY);
                    BCompare = B.GetRectangularPoint(RelativeX, RelativeY);
                }

                Color APixel = A.GetPixel(ACompare);
                Color BPixel = B.GetPixel(BCompare);

                //Console.WriteLine("{0} == {1} = {2}", APixel.ToString(), B.GetPixel(BCompare).ToString(), ImageUtility.ColorCheck(APixel, B.GetPixel(BCompare)));

                if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) ^ ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                {
                    continue;
                }
                else if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) && ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                {
                    Amount += IncreaseAmount;
                    continue;
                }
                else if (ImageUtility.ColorCheck(APixel, BPixel))
                {
                    Amount += IncreaseAmount;
                }
            }

            return(Amount);
        }
Exemplo n.º 4
0
        public static ProbabilisticImage Combine(ProbabilisticImage A, ProbabilisticImage B)
        {
            int SampleCount = Utility.Utility.GetGreatest(A.SampleCount, B.SampleCount);

            Bitmap Result = new Bitmap(A.Source.Width, A.Source.Height);

            for (int i = 0; i < SampleCount; i++)
            {
                double RelativeX = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;
                double RelativeY = Utility.Utility.Generator.NextDouble() * 2.0 - 1.0;

                Point ACompare = new Point();
                Point BCompare = new Point();

                if (A.IsCircle && B.IsCircle)
                {
                    ACompare = A.GetCircularPoint(RelativeX, RelativeY);
                    BCompare = B.GetCircularPoint(RelativeX, RelativeY);
                }
                else
                {
                    ACompare = A.GetRectangularPoint(RelativeX, RelativeY);
                    BCompare = B.GetRectangularPoint(RelativeX, RelativeY);
                }

                Color APixel = A.GetPixel(ACompare);
                Color BPixel = B.GetPixel(BCompare);

                if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) ^ ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                {
                    continue;
                }
                else if (ImageUtility.ColorCheck(A.BackgroundColor, APixel) && ImageUtility.ColorCheck(B.BackgroundColor, BPixel))
                {
                    Result.SetPixel(ACompare.X, ACompare.Y, APixel);
                    continue;
                }
                else if (ImageUtility.ColorCheck(APixel, BPixel))
                {
                    Result.SetPixel(ACompare.X, ACompare.Y, APixel);
                }
            }

            return(new ProbabilisticImage(Result));
        }
Exemplo n.º 5
0
        public static double CompareShapePercentage(ProbabilisticImage A, ProbabilisticImage B)
        {
            double PointCount = Math.Pow(A.R, 2);
            double Amount = 0.0, IncreaseAmount = 1.0 / PointCount;

            for (int x = -A.R; x < A.R; x++)
            {
                for (int y = -A.R; y < A.R; y++)
                {
                    double RelativeX = (double)x / (double)A.R;
                    double RelativeY = (double)y / (double)A.R;

                    Point ACompare = new Point();
                    Point BCompare = new Point();

                    if (A.IsCircle && B.IsCircle)
                    {
                        ACompare = A.GetCircularPoint(RelativeX, RelativeY);
                        BCompare = B.GetCircularPoint(RelativeX, RelativeY);
                    }
                    else
                    {
                        ACompare = A.GetRectangularPoint(RelativeX, RelativeY);
                        BCompare = B.GetRectangularPoint(RelativeX, RelativeY);
                    }

                    Color APixel = A.GetPixel(ACompare);
                    Color BPixel = B.GetPixel(BCompare);

                    //Console.WriteLine("{0} == {1} = {2}", APixel.ToString(), B.GetPixel(BCompare).ToString(), ImageUtility.ColorCheck(APixel, B.GetPixel(BCompare)));

                    //If neither is a background color, then it must be part of the main picture, and therefore the shape is the same here.
                    if ((!ImageUtility.ColorCheck(A.BackgroundColor, APixel)) == (!ImageUtility.ColorCheck(B.BackgroundColor, BPixel)))
                    {
                        Amount += IncreaseAmount;
                    }
                }
            }

            return(Amount);
        }