private string DoWholeTissueSegmentation(Image <Bgr, byte> img, out Image <Gray, byte> mask, string filename)
        {
            WholeTissueSegmentation seg = new WholeTissueSegmentation(img, registrationParameters.WholeTissueSegParams);

            seg.Execute();
            mask = seg.GetOutput().Clone();
            seg.Dispose();
            string filepathMask = registrationParameters.OutputDirectory + filename;

            ReadWriteUtils.WriteUMatToFile(filepathMask, mask.ToUMat());
            return(filepathMask);
        }
        private string GetWholeParticleMaskFilename(string filename)
        {
            string            outputFilename = ReadWriteUtils.GetOutputDirectory(_parameters, _parameters.Iteration) + "\\mask_" + Path.GetFileName(filename);
            Image <Bgr, byte> image          = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(filename);

            WholeTissueSegmentation segImage = new WholeTissueSegmentation(image, _parameters.WholeTissueSegParams);

            segImage.Execute();
            segImage.GetOutput().Save(outputFilename);
            segImage.Dispose();
            return(outputFilename);
        }
        /// <summary>
        /// Do segmentation of inner structures of the tissue for a given image.
        /// </summary>
        /// <param name="filename">image filename</param>
        /// <param name="parameters">registration parameters containing segmentation params</param>
        /// <returns>returns the segmentation instance</returns>
        private InnerTissueSegmentation GetInnerStructureSegmentation(string filename)
        {
            Image <Bgr, byte> image = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(filename);

            WholeTissueSegmentation segImage = new WholeTissueSegmentation(image, _parameters.WholeTissueSegParams);

            segImage.Execute();
            Image <Gray, byte> wholeMask = segImage.GetOutput().Clone();

            segImage.Dispose();

            InnerTissueSegmentation innerSegImage = new InnerTissueSegmentation(image, wholeMask, _parameters.InnerStructuresSegParams);

            innerSegImage.Execute();
            return(innerSegImage);
        }
Exemple #4
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (image != null)
            {
                WholeTissueSegmentation segImage = new WholeTissueSegmentation(image, segmentationParametersWholeTissue);
                segImage.Execute();
                Image <Gray, byte> mask = segImage.GetOutput().Clone();
                segImage.Dispose();

                if (mask != null)
                {
                    InnerTissueSegmentation seg = new InnerTissueSegmentation(image.Clone(), mask.Clone(), segmentationParametersInnerTissue);
                    seg.Execute();
                    List <UMat> result = seg.GetOutput();
                    UMat        a      = new UMat();
                    result[0].Clone().ConvertTo(a, Emgu.CV.CvEnum.DepthType.Cv8U);
                    UMat b = new UMat();
                    result[1].Clone().ConvertTo(b, Emgu.CV.CvEnum.DepthType.Cv8U);
                    seg.Dispose();

                    if (pictureBoxSegmentation1.Image != null)
                    {
                        this.Invoke(new MethodInvoker(delegate() {
                            pictureBoxSegmentation1.Image.Dispose();
                            pictureBoxSegmentation1.Image = null;
                        }));
                    }
                    pictureBoxSegmentation1.Image = a.Bitmap;

                    if (pictureBoxSegmentation2.Image != null)
                    {
                        this.Invoke(new MethodInvoker(delegate() {
                            pictureBoxSegmentation2.Image.Dispose();
                            pictureBoxSegmentation2.Image = null;
                        }));
                    }
                    pictureBoxSegmentation2.Image = b.Bitmap;
                }
            }

            Cursor.Current = Cursors.Default;
        }
Exemple #5
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            if (mask != null)
            {
                mask.Dispose();
            }

            if (image != null)
            {
                Cursor.Current = Cursors.WaitCursor;

                SetSegmentationParameters();

                WholeTissueSegmentation segImage = new WholeTissueSegmentation(image, segmentationParameters);
                segImage.Execute();
                mask = segImage.GetOutput().Clone();
                segImage.Dispose();

                pictureBoxMask.Image = mask.Bitmap;

                Cursor.Current = Cursors.Default;
            }
        }