Exemplo n.º 1
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.º 2
0
 /* Повторяемость Моравека */
 private void button8_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked || radioButton6.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);
         Moravek SdvigMoravek = new Moravek(SdvigImg, MoraverRadius, MoravekDolya);
         SdvigMoravek.ImageWithPoints.Draw(pictureBox19);
     }
     if (radioButton2.Checked || radioButton6.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);
         Moravek RotateMoravek = new Moravek(RotateImg, MoraverRadius, MoravekDolya);
         RotateMoravek.ImageWithPoints.Draw(pictureBox21);
     }
     if (radioButton3.Checked || radioButton6.Checked)
     {
         /*Шум*/
         double[,] NoiseMtx = F.Noise(GrayImg.GrayMatrix, IWidth, IHeight, 30);
         Img     NoiseImg     = new Img(NoiseMtx, IWidth, IHeight);
         Moravek NoiseMoravek = new Moravek(NoiseImg, MoraverRadius, MoravekDolya);
         NoiseMoravek.ImageWithPoints.Draw(pictureBox23);
     }
     if (radioButton4.Checked || radioButton6.Checked)
     {
         /*Контрастность*/
         byte[,] ContrastMtx = F.Contrast(GrayImg.GrayMatrix, IWidth, IHeight, 35);
         Img     ContrastImg     = new Img(ContrastMtx, IWidth, IHeight);
         Moravek ContrastMoravek = new Moravek(ContrastImg, MoraverRadius, MoravekDolya);
         ContrastMoravek.ImageWithPoints.Draw(pictureBox25);
     }
     if (radioButton5.Checked || radioButton6.Checked)
     {
         /*Яркость*/
         byte[,] BrightMtx = F.Brightness(GrayImg.GrayMatrix, IWidth, IHeight, 50);
         Img     BrightImg     = new Img(BrightMtx, IWidth, IHeight);
         Moravek BrightMoravek = new Moravek(BrightImg, MoraverRadius, MoravekDolya);
         BrightMoravek.ImageWithPoints.Draw(pictureBox27);
     }
 }