コード例 #1
0
        private Bitmap DrawCircles(Image <Rgb, byte> img)
        {
            var settings = new CalculatorSettings()
            {
                Color             = ChoosenColor_PictureBox.BackColor,
                Threshold         = Convert.ToInt32(Threshold_UpDown.Value),
                NumberOfTriangles = Convert.ToInt32(Triangles_UpDown.Value)
            };

            Calculator = new CircumscribedCirclesFinder(img, settings);

            var l = Calculator.FindTriangleContour();

            foreach (var el in l)
            {
                img.Draw(el.Circle, new Rgb(0, 0, 255), 2);

                var label = new Label
                {
                    Location  = PointScaler.ScaleToPictureBox(el.LabelPosition),
                    Text      = el.Index.ToString(),
                    AutoSize  = true,
                    Visible   = true,
                    ForeColor = ChoosenColor_PictureBox.BackColor.InvertColor(),
                    BackColor = Color.Transparent
                };

                Image_PictureBox.Controls.Add(label);
            }
            return(img.ToBitmap());
        }
コード例 #2
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     SourceImage            = Resources.test_image;
     PointScaler            = new PointScaler(Image_PictureBox.Image.Size, Image_PictureBox.Size);
     OpenFile_Dialog.Filter = OpenFileFilter;
     SaveFile_Dialog.Filter = SaveFileFilter;
     Set_Threshold_UpDown();
 }
コード例 #3
0
 private void OpenImage_Button_Click(object sender, EventArgs e)
 {
     OpenFile_Dialog.FileName = "";
     if (OpenFile_Dialog.ShowDialog() == DialogResult.OK)
     {
         SourceImage            = new Bitmap(OpenFile_Dialog.FileName);
         Image_PictureBox.Image = SourceImage;
         Image_PictureBox.Controls.Clear();
         PointScaler = new PointScaler(Image_PictureBox.Image.Size, Image_PictureBox.Size);
     }
 }
コード例 #4
0
        private void SaveImage_Button_Click(object sender, EventArgs e)
        {
            if (SaveFile_Dialog.ShowDialog() == DialogResult.OK)
            {
                using (var g = Graphics.FromImage(Image_PictureBox.Image))
                {
                    foreach (var el in Image_PictureBox.Controls)
                    {
                        var label = (Label)el;
                        g.DrawString(label.Text, DefaultFont, new SolidBrush(label.ForeColor),
                                     PointScaler.ScaleToSource(Image_PictureBox.Size, label.Location));
                    }
                }

                Image_PictureBox.Image.Save(SaveFile_Dialog.FileName);
            }
        }