public static VectorOfVectorOfPoint findApproxContours(IImage image, int threshold = 140)
 {
     return(ContourFinder.getApproxContour(
                ContourFinder.findContours(
                    ImageTransformAlgorithms.getThreshold(
                        ImageTransformAlgorithms.pyramideDec(image), threshold))));
 }
 private void findContoursButton_Click(object sender, EventArgs e)
 {
     try
     {
         imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                              ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)));
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Fromat Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message, "Null Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                String currentContuor = comboBox1.SelectedItem.ToString();

                if (currentContuor == "Triangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getTriangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Rectangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getRectangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Circles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image, ContourFinder.getCircles(imageBox1.Image, int.Parse(textBox1.Text)));
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Fromat Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Null Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }