Example #1
0
        private void openImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Изображения (*.bmp, *.png, *.jpg, *jpeg)|*.bmp;*.png;*.jpg;*jpeg|All files(*.*)|*.*";
            if (openFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            try
            {
                image     = Image.FromFile(openFileDialog.FileName);
                bitmapImg = new Bitmap(openFileDialog.FileName);
            }
            catch (OutOfMemoryException ex)
            {
                MessageBox.Show("Ошибка чтения картинки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (bitmapImg.Size.Height != 256 || bitmapImg.Width != 256)
            {
                bitmapImg = ProccesingImage.ResizeImg(ref bitmapImg, 256);
            }
            originalPictureBox.Image = bitmapImg;
            newPictureBox.Image      = bitmapImg;
        }
Example #2
0
 private void ResizeButton_Click(object sender, EventArgs e)
 {
     if (bitmapImg != null)
     {
         try
         {
             int    n = int.Parse(resizeComboBox.Text);
             Bitmap newImg;
             Task.Run(() =>
             {
                 newImg = ProccesingImage.DecreaseImageResolution(new Bitmap(bitmapImg), n);
                 newPictureBox.Image = newImg;
                 Invoke((Action)(() =>
                 {
                     newPictureBox.Refresh();
                     originalPictureBox.Refresh();
                     RefrechBarGraph();
                 }));
             });
         }
         catch
         {
             MessageBox.Show("Выберите значение.");
         }
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }
Example #3
0
 //пороговая обработка
 private void ThresholdButton_Click(object sender, EventArgs e)
 {
     if (bitmapImg != null)
     {
         try
         {
             Bitmap newImg;
             Task.Run(() =>
             {
                 Invoke((Action)(() =>
                 {
                     newImg = ProccesingImage.ThresholdProcessing(new Bitmap(bitmapImg), redTrackBar.Value,
                                                                  greenTrackBar.Value,
                                                                  blueTrackBar.Value);
                     newPictureBox.Image = newImg;
                     newPictureBox.Refresh();
                     originalPictureBox.Refresh();
                     RefrechBarGraph();
                 }));
             });
         }
         catch
         {
             MessageBox.Show("Введено некорректное значение.");
         }
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }
Example #4
0
 private void RandomReplaceButton_Click(object sender, EventArgs e)
 {
     if (bitmapImg != null)
     {
         try
         {
             int n = Int16.Parse(precentTextBox.Text);
             if (n > 100)
             {
                 throw new Exception();
             }
             Bitmap newImg;
             Task.Run(() =>
             {
                 newImg = ProccesingImage.RandomReplacePixel(new Bitmap(bitmapImg), n);
                 newPictureBox.Image = newImg;
                 Invoke((Action)(() =>
                 {
                     newPictureBox.Refresh();
                     originalPictureBox.Refresh();
                     RefrechBarGraph();
                 }));
             });
         }
         catch
         {
             MessageBox.Show("Введено некорректное значение.");
         }
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }
Example #5
0
 private void RefrechBarGraph()
 {
     if (bitmapImg != null)
     {
         Bitmap newImg;
         newImg = ProccesingImage.CreateBarGraph(new Bitmap((Bitmap)newPictureBox.Image));
         barGraphPictureBox.Image = newImg;
         newPictureBox.Refresh();
         originalPictureBox.Refresh();
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }
Example #6
0
 private void FragmentButton_Click(object sender, EventArgs e)
 {
     if (bitmapImg != null)
     {
         Bitmap newImg;
         Task.Run(() =>
         {
             newImg = ProccesingImage.FragmentCut(new Bitmap(bitmapImg));
             newPictureBox.Image = newImg;
             Invoke((Action)(() =>
             {
                 newPictureBox.Refresh();
                 originalPictureBox.Refresh();
                 RefrechBarGraph();
             }));
         });
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }
Example #7
0
 /// <summary>
 /// Метод, который осуществляет квантование изображения
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void QuantButton_Click(object sender, EventArgs e)
 {
     if (bitmapImg != null)
     {
         try
         {
             int    n      = int.Parse(quantComboBox.Text);
             Bitmap newImg = ProccesingImage.Quantization(new Bitmap(bitmapImg), n);
             newPictureBox.Image = newImg;
             newPictureBox.Refresh();
             originalPictureBox.Refresh();
             RefrechBarGraph();
         }
         catch
         {
             MessageBox.Show("Выберите значение.");
         }
     }
     else
     {
         MessageBox.Show("Изображение не загружено.");
     }
 }