예제 #1
0
        private void buttonSegment_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            List <List <Rectangle> > obj_contours = new List <List <Rectangle> >();

            foreach (string path in WsiPaths)
            {
                try
                {
                    Image <Bgr, byte> image = WSIExtraction.Extraction.ExtractImageFromWSI(path, (int)numericUpDown1.Value);
                    ReadWriteUtils.WriteBitmapAsPng(image.Bitmap, ApplicationContext.OutputPath + "\\" + Path.GetFileNameWithoutExtension(path) + ".png");
                    int minContourSize         = ImageUtils.GetPercentualImagePixelCount(image, ((float)this.hScrollBarMinContourSize.Value / 100.0f));
                    List <Rectangle> extracted = WSIExtraction.Extraction.ExtractObjects(image, this.hScrollBarThreshold.Value, minContourSize, out Image <Bgr, byte> image_debug);
                    obj_contours.Add(extracted);
                    AddObjectsFromContours(image, extracted, path, 7);
                } catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    MessageBox.Show(ex.Message);
                    return;
                } finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

            EnableButtons();
            this.Invalidate();
        }