Exemplo n.º 1
0
        public SIFT(Img begimage, int harrisradius, double harrisporog, int npoins, int s)
        {
            BeginImage   = new Img(begimage.Bitmap);
            HarrisRadius = harrisradius;
            HarrisPorog  = harrisporog;
            NPoints      = npoins;
            S            = s;

            Piramids();
            FindPoints();
        }
Exemplo n.º 2
0
        /* Моравек */
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox3.Text != "" && textBox4.Text != "")
            {
                try
                {
                    MoraverRadius = Convert.ToInt32(textBox3.Text);
                    MoravekDolya  = Convert.ToDouble(textBox4.Text);

                    GrayImg.Draw(pictureBox8);
                    GrayImg.Draw(pictureBox10);

                    Moravek = new Moravek(GrayImg, MoraverRadius, MoravekDolya);

                    Img SI = new Img(Moravek.S, IWidth, IHeight);
                    SI.Draw(pictureBox9);

                    Moravek.ImageWithPoints.Draw(pictureBox7);
                    Moravek.ImageWithPoints.Save(BasePath + "Lab 3/Moravek.png");

                    label9.Text = "Оператор Моравека (Точек: " + Moravek.NPoints + ")";

                    Moravek.ImageWithPoints.Draw(pictureBox12);
                    label14.Text = "Точек: " + Moravek.NPoints;
                    label13.Text = "Точек: 0";

                    Moravek.ImageWithPoints.Draw(pictureBox20);
                    Moravek.ImageWithPoints.Draw(pictureBox22);
                    Moravek.ImageWithPoints.Draw(pictureBox24);
                    Moravek.ImageWithPoints.Draw(pictureBox26);
                    Moravek.ImageWithPoints.Draw(pictureBox28);

                    Bitmap bmp = new Bitmap(IWidth, IHeight, PixelFormat.Format32bppArgb);
                    pictureBox11.Image = bmp;
                    pictureBox19.Image = bmp;
                    pictureBox21.Image = bmp;
                    pictureBox23.Image = bmp;
                    pictureBox25.Image = bmp;
                    pictureBox27.Image = bmp;

                    button6.Enabled = true;
                    button8.Enabled = true;
                }
                catch
                {
                    MessageBox.Show("Введите данные корректно!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите данные!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public Harris(Img image, int windowradius, double r)
        {
            Image        = image;
            WindowRadius = windowradius;
            R            = r;

            GaussMatrix = new GaussCore(windowradius, 1);
            MTX         = F.Svertka(Image.GrayMatrixDouble, Image.Width, Image.Height, GaussMatrix.Matrix, GaussMatrix.Radius, 1);

            Derivative();
            Minl();
            IntPoints1();
            PColor(1);
        }
Exemplo n.º 4
0
        public Moravek(Img image, int windowradius, double r)
        {
            Image = image;

            GaussCore GaussMatrix = new GaussCore(1);

            Mtx          = F.Svertka(Image.GrayMatrixDouble, Image.Width, Image.Height, GaussMatrix.Matrix, GaussMatrix.Radius, 1);
            WindowRadius = windowradius;
            R            = r;

            MoravekS();
            IntPoints1();
            IWP(1);
        }
Exemplo n.º 5
0
        /* Собель */
        private void button2_Click(object sender, EventArgs e)
        {
            GrayImg.Draw(pictureBox6);

            Sobel = new double[IHeight, IWidth];
            double dx = 0.0;
            double dy = 0.0;

            for (int y = 0; y < IHeight; y++)
            {
                for (int x = 0; x < IWidth; x++)
                {
                    dx          = Math.Pow(DerivativeX[y, x], 2);
                    dy          = Math.Pow(DerivativeY[y, x], 2);
                    Sobel[y, x] = Math.Sqrt(dx + dy);
                }
            }

            SobelImg = new Img(Sobel, IWidth, IHeight);
            SobelImg.Draw(pictureBox5);
            SobelImg.Save(BasePath + "Lab 1/Sobel.png");
        }
Exemplo n.º 6
0
        public Form1()
        {
            InitializeComponent();
            /* Очищаем предыдущие результаты */
            F.ClearDir(BasePath + "Result");
            F.ClearDir(BasePath + "Lab 1");
            F.ClearDir(BasePath + "Lab 2");
            F.ClearDir(BasePath + "Lab 2/Core");
            F.ClearDir(BasePath + "Lab 3");
            F.ClearDir(BasePath + "Lab 4");
            F.ClearDir(BasePath + "Lab 5");
            F.ClearDir(BasePath + "Lab 6");
            /*-------------------------------*/

            BeginImg = new Img(BasePath + "Begin/BeginImage1.png");
            GrayImg  = new Img(BeginImg.GrayMatrix, BeginImg.Width, BeginImg.Height);
            GrayImg.Save(BasePath + "Result/GrayImage.png");

            IWidth  = BeginImg.Width;
            IHeight = BeginImg.Height;

            BeginImg.Draw(pictureBox1);
            GrayImg.Draw(pictureBox2);
        }
Exemplo n.º 7
0
        private void Piramids()
        {
            double sigma0 = 1.6;                              // sigma 0
            double k      = Math.Pow(2.0, (1.0 / (double)S)); // Интервал между масштабами

            int minr = Math.Min(BeginImage.Width, BeginImage.Height);

            O = 0;
            while (minr > 32)
            {
                minr /= 2;
                O++;
            }

            Piramida = new Img[O + 1, S + 3];
            DoG      = new Img[O + 1, S + 2];

            Img    TekImg   = new Img(BeginImage.Bitmap);
            double sigmaD   = sigma0;                      // Действительная сигма
            double sigmaTEK = sigma0;
            int    qq       = 1;

            GaussCore GaussMatrix = new GaussCore(sigma0);

            TekImg.SvertkaWithNormalize(GaussMatrix.Matrix, GaussMatrix.Radius, 1);
            Piramida[0, 0] = new Img(TekImg.Bitmap);

            GlobalSigma = new double[O + 1, S + 3];
            Sigma       = new double[O + 1, S + 3];


            Sigma[0, 0]       = sigmaTEK;
            GlobalSigma[0, 0] = sigmaD;

            for (int o = 0; o < O + 1; o++)
            {
                TekImg = new Img(Piramida[o, 0].Bitmap);
                for (int s = 1; s < S + 3; s++)
                {
                    double sigma1 = sigma0 * Math.Pow(k, (s - 1));
                    double sigma2 = sigma0 * Math.Pow(k, s);
                    sigmaTEK          = Math.Sqrt(sigma2 * sigma2 - sigma1 * sigma1); // Текущая сигма
                    Sigma[o, s]       = sigma2;
                    sigmaD            = sigma0 * Math.Pow(k, qq);
                    GlobalSigma[o, s] = sigmaD;
                    qq++;
                    GaussMatrix = new GaussCore(sigmaTEK);
                    TekImg.SvertkaWithNormalize(GaussMatrix.Matrix, GaussMatrix.Radius, 1);
                    Piramida[o, s] = new Img(TekImg.Bitmap);

                    if ((o + 1) != (O + 1) && s == S)
                    {
                        Piramida[o + 1, 0] = new Img(TekImg.Bitmap);
                        Piramida[o + 1, 0].Downsample();

                        Sigma[o + 1, 0]       = sigma0;
                        GlobalSigma[o + 1, 0] = sigmaD;
                    }
                }
                qq = qq - 2;
            }

            for (int o = 0; o < O + 1; o++)
            {
                for (int s = 0; s < S + 2; s++)
                {
                    double[,] RMtx = new double[Piramida[o, 0].Height, Piramida[o, 0].Width];
                    for (int y = 0; y < Piramida[o, 0].Height; y++)
                    {
                        for (int x = 0; x < Piramida[o, 0].Width; x++)
                        {
                            RMtx[y, x] = Math.Abs(Piramida[o, s + 1].GrayMatrixDouble[y, x] - Piramida[o, s].GrayMatrixDouble[y, x]);
                        }
                    }
                    DoG[o, s] = new Img(RMtx, Piramida[o, 0].Width, Piramida[o, 0].Height);
                    DoG[o, s].Save(BasePath + "Lab 6/i" + Convert.ToString(o) + Convert.ToString(s) + ".png");
                }
            }
        }
Exemplo n.º 8
0
        /* Дескрипторы (Лаб 6)*/
        private void button12_Click(object sender, EventArgs e)
        {
            if (textBox18.Text != "" && textBox17.Text != "" && textBox16.Text != "" && textBox15.Text != "")
            {
                //try
                //{
                int    HarrisRadius = Convert.ToInt32(textBox17.Text);
                double HarrisDolya  = Convert.ToDouble(textBox16.Text);
                int    Npoints      = Convert.ToInt32(textBox15.Text);
                int    Mashtab      = Convert.ToInt32(textBox18.Text);

                Img BegImg1 = new Img(GrayImg.GrayMatrix, IWidth, IHeight);

                /*-------------------------*/

                /*
                 * int size = Convert.ToInt32(Math.Ceiling(Math.Sqrt(IWidth * IWidth + IHeight * IHeight)));
                 * Bitmap RotateBMP = new Bitmap(size, size, PixelFormat.Format32bppArgb);
                 * for (int y = 0; y < size; y++)
                 * {
                 *  for (int x = 0; x < size; x++)
                 *  {
                 *      RotateBMP.SetPixel(x, y, Color.White);
                 *  }
                 * }
                 * int o = (size - IHeight) / 2;
                 * int oo = (size - IWidth) / 2;
                 * for (int y = o; y < IHeight + o; y++)
                 * {
                 *  for (int x = oo; x < IWidth + oo; x++)
                 *  {
                 *      RotateBMP.SetPixel(x, y, GrayImg.Bitmap.GetPixel(x - oo, y - o));
                 *  }
                 * }
                 * RotateBMP = F.RotateImage(RotateBMP, 45.0F);
                 * Img BegImg2 = new Img(RotateBMP);
                 */
                /*
                 * byte[,] SdvigMtx = F.Sdvig(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, out int nWidth, out int nHeight, 0, -50);
                 * TempImg = new Img(SdvigMtx, nWidth, nHeight);
                 *
                 * byte[,] ContrastMtx = F.Contrast(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, -10);
                 * Img BegImg2 = new Img(ContrastMtx, TempImg.Width, TempImg.Height);
                 */
                /*--------------------------*/

                //Img BegImg2 = new Img(BasePath + "Temp/GrayImage.png");

                BegImg1.Draw(pictureBox50);
                //BegImg2.Draw(pictureBox49);

                SIFT SIFT1 = new SIFT(BegImg1, HarrisRadius, HarrisDolya, Npoints, Mashtab);


                Graphics g = Graphics.FromImage(BegImg1.Bitmap);

                for (int i = 0; i < SIFT1.InterestingPoints.Count; i++)
                {
                    int x0  = SIFT1.InterestingPoints[i].X - SIFT1.InterestingPoints[i].Radius;
                    int y0  = SIFT1.InterestingPoints[i].Y - SIFT1.InterestingPoints[i].Radius;
                    int d   = SIFT1.InterestingPoints[i].Radius * 2;
                    Pen pen = new Pen(Brushes.Blue, 1);
                    g.DrawEllipse(pen, x0, y0, d, d);
                }



                pictureBox49.Image = BegImg1.Bitmap;

                //}
                //catch
                //{
                //    MessageBox.Show("Введите данные корректно!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //}
            }
            else
            {
                MessageBox.Show("Введите данные!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        /* Дескрипторы (Лаб 5)*/
        private void button11_Click(object sender, EventArgs e)
        {
            if (textBox14.Text != "" && textBox13.Text != "" && textBox12.Text != "")
            {
                try
                {
                    int    HarrisRadius = Convert.ToInt32(textBox14.Text);
                    double HarrisDolya  = Convert.ToDouble(textBox13.Text);
                    int    Npoints      = Convert.ToInt32(textBox12.Text);

                    Img BegImg1 = new Img(GrayImg.GrayMatrix, IWidth, IHeight);

                    /*-------------------------*/
                    int    size      = Convert.ToInt32(Math.Ceiling(Math.Sqrt(IWidth * IWidth + IHeight * IHeight)));
                    Bitmap RotateBMP = new Bitmap(size, size, PixelFormat.Format32bppArgb);
                    for (int y = 0; y < size; y++)
                    {
                        for (int x = 0; x < size; x++)
                        {
                            RotateBMP.SetPixel(x, y, Color.White);
                        }
                    }
                    int o  = (size - IHeight) / 2;
                    int oo = (size - IWidth) / 2;
                    for (int y = o; y < IHeight + o; y++)
                    {
                        for (int x = oo; x < IWidth + oo; x++)
                        {
                            RotateBMP.SetPixel(x, y, GrayImg.Bitmap.GetPixel(x - oo, y - o));
                        }
                    }
                    RotateBMP = F.RotateImage(RotateBMP, 45.0F);
                    Img BegImg2 = new Img(RotateBMP);

                    /*
                     * byte[,] SdvigMtx = F.Sdvig(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, out int nWidth, out int nHeight, 0, -50);
                     * TempImg = new Img(SdvigMtx, nWidth, nHeight);
                     *
                     * byte[,] ContrastMtx = F.Contrast(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, -10);
                     * Img BegImg2 = new Img(ContrastMtx, TempImg.Width, TempImg.Height);
                     */
                    /*--------------------------*/

                    //Img BegImg2 = new Img(BasePath + "Temp/GrayImage.png");

                    BegImg1.Draw(pictureBox45);
                    BegImg2.Draw(pictureBox43);

                    Harris Harris1 = new Harris(BegImg1, HarrisRadius, HarrisDolya);
                    Harris1.ANMS(Npoints);
                    Harris Harris2 = new Harris(BegImg2, HarrisRadius, HarrisDolya);
                    Harris2.ANMS(Npoints);

                    Harris1.ImageWithANMS.Draw(pictureBox47);
                    Harris2.ImageWithANMS.Draw(pictureBox46);

                    Harris1.Descript5();
                    Harris2.Descript5();

                    int[]  S        = F.DescriptSootv5(Harris1, Harris2, 16 * 8, 0.8);
                    int    rst      = 20;
                    int    h        = Math.Max(Harris1.ImageWithANMS.Height, Harris2.ImageWithANMS.Height);
                    Bitmap SootvBmp = new Bitmap(Harris1.ImageWithANMS.Width + Harris2.ImageWithANMS.Width + rst, h, PixelFormat.Format32bppArgb);

                    for (int y = 0; y < Harris1.ImageWithANMS.Height; y++)
                    {
                        for (int x = 0; x < Harris1.ImageWithANMS.Width; x++)
                        {
                            SootvBmp.SetPixel(x, y, Harris1.ImageWithANMS.Bitmap.GetPixel(x, y));
                        }
                    }
                    for (int y = 0; y < h; y++)
                    {
                        for (int x = Harris1.ImageWithANMS.Width; x < Harris1.ImageWithANMS.Width + rst; x++)
                        {
                            SootvBmp.SetPixel(x, y, Color.White);
                        }
                    }
                    for (int y = 0; y < Harris2.ImageWithANMS.Height; y++)
                    {
                        for (int x = Harris1.ImageWithANMS.Width + rst; x < Harris1.ImageWithANMS.Width + rst + Harris2.ImageWithANMS.Width; x++)
                        {
                            SootvBmp.SetPixel(x, y, Harris2.ImageWithANMS.Bitmap.GetPixel(x - (Harris1.ImageWithANMS.Width + rst), y));
                        }
                    }

                    Random   rand = new Random();
                    Graphics g    = Graphics.FromImage(SootvBmp);
                    Pen      pen;
                    Point    p1, p2;
                    for (int i = 0; i < Harris1.NewPoints; i++)
                    {
                        if (S[i] != -1)
                        {
                            int ra = rand.Next(0, 101);
                            if (ra >= 0 && ra < 20)
                            {
                                pen = new Pen(Brushes.Blue, 2);
                            }
                            else if (ra >= 20 && ra < 40)
                            {
                                pen = new Pen(Brushes.Green, 2);
                            }
                            else if (ra >= 40 && ra < 60)
                            {
                                pen = new Pen(Brushes.Aqua, 2);
                            }
                            else if (ra >= 60 && ra < 80)
                            {
                                pen = new Pen(Brushes.Yellow, 2);
                            }
                            else
                            {
                                pen = new Pen(Brushes.Violet, 2);
                            }

                            p1 = new Point(Harris1.IntPointsCoord[i, 1], Harris1.IntPointsCoord[i, 0]);
                            p2 = new Point(Harris2.IntPointsCoord[S[i], 1] + (Harris1.ImageWithANMS.Width + rst), Harris2.IntPointsCoord[S[i], 0]);
                            g.DrawLine(pen, p1, p2);
                        }
                    }
                    pictureBox48.Image = SootvBmp;

                    Harris1.ImageWithANMS.Save(BasePath + "Lab 5/HarrisANMS1.png");
                    Harris2.ImageWithANMS.Save(BasePath + "Lab 5/HarrisANMS2.png");
                    SootvBmp.Save(BasePath + "Lab 5/Result.png");
                }
                catch
                {
                    MessageBox.Show("Введите данные корректно!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите данные!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
        /* Дескрипторы (Лаб 4)*/
        private void button10_Click(object sender, EventArgs e)
        {
            if (textBox11.Text != "" && textBox10.Text != "" && textBox9.Text != "")
            {
                try
                {
                    int    HarrisRadius = Convert.ToInt32(textBox11.Text);
                    double HarrisDolya  = Convert.ToDouble(textBox10.Text);
                    int    Npoints      = Convert.ToInt32(textBox9.Text);

                    Img BegImg1 = new Img(GrayImg.GrayMatrix, IWidth, IHeight);

                    /*-------------------------*/
                    int    size      = Convert.ToInt32(Math.Ceiling(Math.Sqrt(IWidth * IWidth + IHeight * IHeight)));
                    Bitmap RotateBMP = new Bitmap(size, size, PixelFormat.Format32bppArgb);
                    for (int y = 0; y < size; y++)
                    {
                        for (int x = 0; x < size; x++)
                        {
                            RotateBMP.SetPixel(x, y, Color.White);
                        }
                    }
                    int o  = (size - IHeight) / 2;
                    int oo = (size - IWidth) / 2;
                    for (int y = o; y < IHeight + o; y++)
                    {
                        for (int x = oo; x < IWidth + oo; x++)
                        {
                            RotateBMP.SetPixel(x, y, GrayImg.Bitmap.GetPixel(x - oo, y - o));
                        }
                    }
                    RotateBMP = F.RotateImage(RotateBMP, 5.0F);
                    Img TempImg = new Img(RotateBMP);

                    byte[,] SdvigMtx = F.Sdvig(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, out int nWidth, out int nHeight, 0, -100);
                    TempImg          = new Img(SdvigMtx, nWidth, nHeight);

                    byte[,] ContrastMtx = F.Contrast(TempImg.GrayMatrix, TempImg.Width, TempImg.Height, -10);
                    Img BegImg2 = new Img(ContrastMtx, TempImg.Width, TempImg.Height);
                    /*--------------------------*/

                    BegImg1.Draw(pictureBox30);
                    BegImg2.Draw(pictureBox29);

                    Harris Harris1 = new Harris(BegImg1, HarrisRadius, HarrisDolya);
                    Harris1.ANMS(Npoints);
                    Harris Harris2 = new Harris(BegImg2, HarrisRadius, HarrisDolya);
                    Harris2.ANMS(Npoints);

                    Harris1.ImageWithANMS.Draw(pictureBox42);
                    Harris2.ImageWithANMS.Draw(pictureBox41);

                    Harris1.Descript4();
                    Harris2.Descript4();

                    int[]  S        = F.DescriptSootv4(Harris1, Harris2, 8 * 16, 0.8);
                    int    rst      = 20;
                    int    h        = Math.Max(Harris1.ImageWithANMS.Height, Harris2.ImageWithANMS.Height);
                    Bitmap SootvBmp = new Bitmap(Harris1.ImageWithANMS.Width + Harris2.ImageWithANMS.Width + rst, h, PixelFormat.Format32bppArgb);

                    for (int y = 0; y < Harris1.ImageWithANMS.Height; y++)
                    {
                        for (int x = 0; x < Harris1.ImageWithANMS.Width; x++)
                        {
                            SootvBmp.SetPixel(x, y, Harris1.ImageWithANMS.Bitmap.GetPixel(x, y));
                        }
                    }
                    for (int y = 0; y < h; y++)
                    {
                        for (int x = Harris1.ImageWithANMS.Width; x < Harris1.ImageWithANMS.Width + rst; x++)
                        {
                            SootvBmp.SetPixel(x, y, Color.White);
                        }
                    }
                    for (int y = 0; y < Harris2.ImageWithANMS.Height; y++)
                    {
                        for (int x = Harris1.ImageWithANMS.Width + rst; x < Harris1.ImageWithANMS.Width + rst + Harris2.ImageWithANMS.Width; x++)
                        {
                            SootvBmp.SetPixel(x, y, Harris2.ImageWithANMS.Bitmap.GetPixel(x - (Harris1.ImageWithANMS.Width + rst), y));
                        }
                    }

                    Graphics g = Graphics.FromImage(SootvBmp);
                    Pen      pen = new Pen(Brushes.Blue, 2);
                    Point    p1, p2;
                    for (int i = 0; i < Harris1.NewPoints; i++)
                    {
                        if (S[i] != -1)
                        {
                            p1 = new Point(Harris1.IntPointsCoord[i, 1], Harris1.IntPointsCoord[i, 0]);
                            p2 = new Point(Harris2.IntPointsCoord[S[i], 1] + (Harris1.ImageWithANMS.Width + rst), Harris2.IntPointsCoord[S[i], 0]);
                            g.DrawLine(pen, p1, p2);
                        }
                    }
                    pictureBox44.Image = SootvBmp;

                    Harris1.ImageWithANMS.Save(BasePath + "Lab 4/HarrisANMS1.png");
                    Harris2.ImageWithANMS.Save(BasePath + "Lab 4/HarrisANMS2.png");
                    SootvBmp.Save(BasePath + "Lab 4/Result.png");
                }
                catch
                {
                    MessageBox.Show("Введите данные корректно!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите данные!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
 /* Повторяемость Харриса */
 private void button9_Click(object sender, EventArgs e)
 {
     if (radioButton7.Checked || radioButton12.Checked)
     {
         /*Сдвиг*/
         byte[,] SdvigMtx = F.Sdvig(GrayImg.GrayMatrix, GrayImg.Width, GrayImg.Height, out int nWidth, out int nHeight, 50, 20);
         Img    SdvigImg    = new Img(SdvigMtx, nWidth, nHeight);
         Harris SdvigHarris = new Harris(SdvigImg, HarrisRadius, HarrisDolya);
         SdvigHarris.ImageWithPoints.Draw(pictureBox31);
     }
     if (radioButton8.Checked || radioButton12.Checked)
     {
         /*Поворот*/
         int    size      = Convert.ToInt32(Math.Ceiling(Math.Sqrt(IWidth * IWidth + IHeight * IHeight)));
         Bitmap RotateBMP = new Bitmap(size, size, PixelFormat.Format32bppArgb);
         for (int y = 0; y < size; y++)
         {
             for (int x = 0; x < size; x++)
             {
                 RotateBMP.SetPixel(x, y, Color.White);
             }
         }
         int o  = (size - IHeight) / 2;
         int oo = (size - IWidth) / 2;
         for (int y = o; y < IHeight + o; y++)
         {
             for (int x = oo; x < IWidth + oo; x++)
             {
                 RotateBMP.SetPixel(x, y, GrayImg.Bitmap.GetPixel(x - oo, y - o));
             }
         }
         RotateBMP = F.RotateImage(RotateBMP, 30.0F);
         Img    RotateImg    = new Img(RotateBMP);
         Harris RotateHarris = new Harris(RotateImg, HarrisRadius, HarrisDolya);
         RotateHarris.ImageWithPoints.Draw(pictureBox33);
     }
     if (radioButton9.Checked || radioButton12.Checked)
     {
         /*Шум*/
         double[,] NoiseMtx = F.Noise(GrayImg.GrayMatrix, IWidth, IHeight, 30);
         Img    NoiseImg    = new Img(NoiseMtx, IWidth, IHeight);
         Harris NoiseHarris = new Harris(NoiseImg, HarrisRadius, HarrisDolya);
         NoiseHarris.ImageWithPoints.Draw(pictureBox35);
     }
     if (radioButton10.Checked || radioButton12.Checked)
     {
         /*Контрастность*/
         byte[,] ContrastMtx = F.Contrast(GrayImg.GrayMatrix, IWidth, IHeight, 35);
         Img    ContrastImg    = new Img(ContrastMtx, IWidth, IHeight);
         Harris ContrastHarris = new Harris(ContrastImg, HarrisRadius, HarrisDolya);
         ContrastHarris.ImageWithPoints.Draw(pictureBox37);
     }
     if (radioButton11.Checked || radioButton12.Checked)
     {
         /*Яркость*/
         byte[,] BrightMtx = F.Brightness(GrayImg.GrayMatrix, IWidth, IHeight, 50);
         Img    BrightImg    = new Img(BrightMtx, IWidth, IHeight);
         Harris BrightHarris = new Harris(BrightImg, HarrisRadius, HarrisDolya);
         BrightHarris.ImageWithPoints.Draw(pictureBox39);
     }
 }
Exemplo n.º 12
0
        /* Пирамида */
        private void button3_Click(object sender, EventArgs e)
        {
            bool mTr = true;

            if (textBox1.Text == "" || textBox2.Text == "")
            {
                mTr = false;
                MessageBox.Show("Введите данные", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (mTr)
            {
                F.ClearDir(BasePath + "Lab 2");
                F.ClearDir(BasePath + "Lab 2/Core");

                double sigma0 = Convert.ToDouble(textBox1.Text);  // Сигма 0
                int    S      = Convert.ToInt32(textBox2.Text);   // Число масштабов в октаве
                double k      = Math.Pow(2.0, (1.0 / (double)S)); // Интервал между масштабами

                int minr = Math.Min(IWidth, IHeight);
                int O    = 0;                              // Число октав
                while (minr > 32)
                {
                    minr /= 2;
                    O++;
                }

                Img TekImg = new Img(GrayImg.GrayMatrix, IWidth, IHeight);
                TekImg.Save(BasePath + "Lab 2/000.png");
                double sigmaD   = sigma0;                      // Действительная сигма
                double sigmaTEK = sigma0;
                double qq       = 1;

                GaussCore GaussMatrix = new GaussCore(sigma0);
                Img       GaussImg    = new Img(GaussMatrix.Matrix, GaussMatrix.Size, GaussMatrix.Size);
                TekImg.SvertkaWithNormalize(GaussMatrix.Matrix, GaussMatrix.Radius, 1);
                TekImg.Save(BasePath + "Lab 2/" + "00"
                            + " - S1=" + Convert.ToString(Math.Round(sigma0, 2)) + " - Sd=" + Convert.ToString(Math.Round(sigma0, 2)) + ".png");
                GaussImg.Save(BasePath + "Lab 2/Core/" + "00" + ".png");

                for (int o = 0; o < O; o++)
                {
                    for (int s = 1; s <= S; s++)
                    {
                        double sigma1 = sigma0 * Math.Pow(k, (s - 1));
                        double sigma2 = sigma0 * Math.Pow(k, s);
                        sigmaTEK = Math.Sqrt(sigma2 * sigma2 - sigma1 * sigma1);// Текущая сигма
                        sigmaD   = sigma0 * Math.Pow(k, qq);
                        qq++;
                        GaussMatrix = new GaussCore(sigmaTEK);
                        GaussImg    = new Img(GaussMatrix.Matrix, GaussMatrix.Size, GaussMatrix.Size);
                        TekImg.SvertkaWithNormalize(GaussMatrix.Matrix, GaussMatrix.Radius, 1);
                        TekImg.Save(BasePath + "Lab 2/" + Convert.ToString(o) + Convert.ToString(s)
                                    + " - S1=" + Convert.ToString(Math.Round(sigma2, 2)) + " - Sd=" + Convert.ToString(Math.Round(sigmaD, 2)) + ".png");
                        GaussImg.Save(BasePath + "Lab 2/Core/" + Convert.ToString(o) + Convert.ToString(s) + ".png");
                    }
                    TekImg.Downsample();
                    TekImg.Save(BasePath + "Lab 2/" + Convert.ToString(o + 1) + "0"
                                + " - S1=" + Convert.ToString(Math.Round(sigma0, 2)) + " - Sd=" + Convert.ToString(Math.Round(sigmaD, 2)) + ".png");
                }
            }
        }