Пример #1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if ((listBoxImages.SelectedItem == null) || String.IsNullOrEmpty(listBoxImages.SelectedItem.ToString()))
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            if (File.Exists("Ic_out.png"))
            {
                File.Delete("Ic_out.png");
            }

            pictureBoxResult.Image = null;

            double factor1;
            double factor2;
            double threshold1;
            double threshold2;
            string folder;
            string file;

            double.TryParse(textBoxFactor1.Text, out factor1);
            double.TryParse(textBoxFactor2.Text, out factor2);
            double.TryParse(textBoxThreshold1.Text, out threshold1);
            double.TryParse(textBoxThreshold2.Text, out threshold2);

            folder = System.IO.Path.GetDirectoryName(listBoxImages.SelectedItem.ToString()) + @"\";
            file   = System.IO.Path.GetFileName(listBoxImages.SelectedItem.ToString());

            double[]       _threshold   = new double[] { threshold1, threshold2 };
            MWNumericArray threshold    = new MWNumericArray(_threshold);
            MWNumericArray fudgeFactor1 = new MWNumericArray(factor1);
            MWNumericArray fudgeFactor2 = new MWNumericArray(factor2);
            MWCharArray    path         = new MWCharArray(folder);
            MWCharArray    filename     = new MWCharArray(file);

            ClassMedDetect medDetect = new ClassMedDetect();
            MWArray        MWResult  = medDetect.func_med_detect(path, filename, threshold, fudgeFactor1, fudgeFactor2);

            pictureBoxResult.Image = Image.FromFile("Ic_out.png");

            labelCautnTotal.Text     = String.Format("Кол-во обнаруженных объектов: {0}", (double)((MWNumericArray)MWResult[1]));
            labelSquareTotal.Text    = String.Format("Общая площадь объектов:: {0}", (double)((MWNumericArray)MWResult[2]));
            labelCountSelected.Text  = String.Format("Кол-во выделенных объектов:: {0}", (double)((MWNumericArray)MWResult[3]));
            labelSquareSelected.Text = String.Format("Площадь выделенных объектов: {0}", (double)((MWNumericArray)MWResult[4]));

            Cursor.Current = Cursors.Default;

            MessageBox.Show("Расчет закончен", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #2
0
        static void Main(string[] args)
        {
            double factor1;
            double factor2;
            double threshold1;
            double threshold2;
            string folder;
            string file;

            if (args.Length != 6)
            {
                ///////////////////////////////////////////////////////////////
                // Default settings
                ///////////////////////////////////////////////////////////////
                factor1    = 0.8;
                factor2    = 0.8;
                threshold1 = 0;
                threshold2 = 0.25;
                folder     = @"D:\Projects\MED\Matlab\SourceCode\";
                file       = @"lc_input.tif";
            }
            else
            {
                ///////////////////////////////////////////////////////////////
                // Command line parameters
                ///////////////////////////////////////////////////////////////
                double.TryParse(args[0], out factor1);
                double.TryParse(args[1], out factor2);
                double.TryParse(args[2], out threshold1);
                double.TryParse(args[3], out threshold2);
                folder = args[4];
                file   = args[5];

                factor1    = 0.8;
                factor2    = 0.8;
                threshold1 = 0;
                threshold2 = 0.25;
                folder     = @"D:\Projects\MED\Matlab\SourceCode\";
                file       = @"lc_input.tif";
            }

            Console.WriteLine("Please wait...");
            double[]       _threshold   = new double[] { threshold1, threshold2 };
            MWNumericArray threshold    = new MWNumericArray(_threshold);
            MWNumericArray fudgeFactor1 = new MWNumericArray(factor1);
            MWNumericArray fudgeFactor2 = new MWNumericArray(factor2);
            MWCharArray    path         = new MWCharArray(folder);
            MWCharArray    filename     = new MWCharArray(file);

            ClassMedDetect medDetect = new ClassMedDetect();
            MWArray        MWResult  = medDetect.func_med_detect(path, filename, threshold, fudgeFactor1, fudgeFactor2);

            Console.Clear();
            Console.WriteLine("The calculation successfully completed");
            Console.WriteLine("======================================");
            Console.WriteLine(String.Format("Total objects found: {0}", (double)((MWNumericArray)MWResult[1])));
            Console.WriteLine(String.Format("Total area calculated: {0}", (double)((MWNumericArray)MWResult[2])));
            Console.WriteLine(String.Format("Selected objects found: {0}", (double)((MWNumericArray)MWResult[3])));
            Console.WriteLine(String.Format("Selected area calculated: {0}", (double)((MWNumericArray)MWResult[4])));
            Console.WriteLine("======================================");
            Console.WriteLine();
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }