Exemple #1
0
        public void MathematicialSearchPoint_7Test()          //Проверка ядер свертки
        {
            //arrange
            MathematicialSearchPoint core = new MathematicialSearchPoint7();

            //act
            double[,] exepectedGx = new double[, ]  {
                { 1, 1, 1, 0, -1, -1, -1 }, { 1, 1, 2, 0, -2, -1, -1 }, { 1, 2, 3, 0, -3, -2, -1 },
                { 2, 3, 4, 0, -4, -3, -2 }, { 1, 2, 3, 0, -3, -2, -1 }, { 1, 1, 2, 0, -2, -1, -1 }, { 1, 1, 1, 0, -1, -1, -1 }
            };
            double[,] exepectedGy = new double[, ] {
                { -1, -1, -1, -2, -1, -1, -1 }, { -1, -1, -2, -3, -2, -1, -1 }, { -1, -2, -3, -4, -3, -2, -1 },
                { 0, 0, 0, 0, 0, 0, 0 }, { 1, 2, 3, 4, 3, 2, 1 }, { 1, 1, 2, 3, 2, 1, 1 }, { 1, 1, 1, 2, 1, 1, 1 }
            };
            double[,] actualGx = core.XMatrix;
            double[,] actualGy = core.YMatrix;

            //assert
            Debug.WriteLine("Проверка ядер  свертки Gx и Gy");
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    Assert.AreEqual(exepectedGx[i, j], actualGx[i, j]);
                    Assert.AreEqual(exepectedGy[i, j], actualGy[i, j]);
                }
            }
        }
Exemple #2
0
        public void gradientAtPoint7_IntPoint_Test()              //Проверка градиента  внутренней точки
        {
            //arrange
            IParser parser = new Parser();
            Bitmap  img    = parser.readPNG("Data\\sample_10.png");

            MathematicialSearchPoint core = new MathematicialSearchPoint7();

            core.setImage(img);

            double[,] X = new double[7, 7];
            for (int i = 599; i < 606; i++)
            {
                for (int j = 599; j < 606; j++)
                {
                    X[i - 599, j - 599] = img.GetPixel(i, j).B;   //Матрица окружения точки (602,602)
                }
            }
            double gradX = 0;
            double gradY = 0;
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    gradX += X[i, j] * core.XMatrix[j, i];
                    gradY += X[i, j] * core.YMatrix[j, i];
                }
            }
            //act
            double exepected = Math.Sqrt(gradX * gradX + gradY * gradY);
            double actual    = core.gradientAtPoint(602, 602);
            //assert
            Assert.AreEqual(exepected, actual);
        }
Exemple #3
0
        public void gradientAtPoint7_CornerPoint_Test()              //Проверка градиента  угловой точки
        {
            //arrange
            IParser parser = new Parser();
            Bitmap  img    = parser.readPNG("Data\\sample_10.png");

            //Blue[i, j] = 0.3 * img.GetPixel(i, j).R + 0.59 * img.GetPixel(i, j).G + 0.11 * img.GetPixel(i, j).B;    //Заполнение монохромного изображения

            MathematicialSearchPoint core = new MathematicialSearchPoint7();

            core.setImage(img);
            double[,] X = new double[7, 7];
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    X[i, j] = 0;
                }
            }
            for (int i = 3; i < 7; i++)
            {
                for (int j = 3; j < 7; j++)
                {
                    X[i, j] = img.GetPixel(i - 3, j - 3).B;               //Матрица окружения точки (0,0)
                }
            }
            double gradX = 0;
            double gradY = 0;
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    gradX += X[i, j] * core.XMatrix[j, i];
                    gradY += X[i, j] * core.YMatrix[j, i];
                }
            }
            //act
            double exepected = Math.Sqrt(gradX * gradX + gradY * gradY);
            double actual    = core.gradientAtPoint(0, 0);
            //assert
            Assert.AreEqual(exepected, actual);
        }