private void button1_Click(object sender, EventArgs e)
        {
            int             K = Convert.ToInt32(textBox1.Text.ToString());
            distinct_colors c = new distinct_colors();

            c.get_colors(ImageMatrix);
            MessageBox.Show(c.count.ToString());
            MST tree = new MST(c.count, c.colors);

            tree.MST_Construct();
            tree.total_cost();
            double d = tree.cost;

            MessageBox.Show(d.ToString());
            Cluster cc = new Cluster(tree.L, c.colors, K);

            cc.function();
            cc.Color_Pallette();
            cc.Quantize_the_image(ImageMatrix);
            //----------------------------------------------------------
            double sigma    = double.Parse(txtGaussSigma.Text);
            int    maskSize = (int)nudMaskSize.Value;

            //ImageMatrix = ImageOperations.GaussianFilter1D(ImageMatrix, maskSize, sigma);

            ImageOperations.DisplayImage(ImageMatrix, pictureBox2);
            //----------------------------------------------------------
            //-------------------------------------------------
            var fd = new SaveFileDialog();

            fd.Filter       = "Bmp(*.BMP;)|*.BMP;| Jpg(*Jpg)|*.jpg";
            fd.AddExtension = true;
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                switch (System.IO.Path.GetExtension(fd.FileName).ToUpper())
                {
                case ".BMP":
                    pictureBox2.Image.Save(fd.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
                    break;

                case ".JPG":
                    pictureBox2.Image.Save(fd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                    break;

                case ".PNG":
                    pictureBox2.Image.Save(fd.FileName, System.Drawing.Imaging.ImageFormat.Png);
                    break;

                default:
                    break;
                }
            }
            //-------------------------------------------------
        }
        private void calculate_std_mean()
        {
            double segma = 0;

            tree = new MST(colors.Count, colors);
            tree.MST_Construct();
            MSTree = tree.L;
            tree.total_cost();
            total = tree.cost;
            mean  = total / (MSTree.Count);
            for (int i = 1; i < MSTree.Count; i++)
            {
                segma += (MSTree[i].weight * MSTree[i].weight) - (mean * mean);
            }
            stddiv = Math.Sqrt(segma / MSTree.Count);
            clnum2 = 0;
        }