Esempio n. 1
0
 public SegParamsInnerStructuresForm(List <string> imageFilenames, SegmentationParameters parametersWholeTissue, SegmentationParameters parametersInnerTissue)
 {
     InitializeComponent();
     this.filenames    = imageFilenames;
     this.selectedFile = imageFilenames.FirstOrDefault();
     this.image        = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(this.selectedFile);
     this.segmentationParametersInnerTissue = parametersInnerTissue;
     this.segmentationParametersWholeTissue = parametersWholeTissue;
 }
        private void buttonCalcCoef_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            string fixedImageFilename  = registrationParameters.FixedImageFilename;
            string movingImageFilename = comboBoxMovingImage.SelectedValue.ToString();
            bool   isInnerSeg          = comboBoxSegmentationParams.SelectedIndex == 1;

            // read images
            Image <Bgr, byte> img01 = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(fixedImageFilename);
            Image <Bgr, byte> img02 = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(movingImageFilename);

            // whole particle seg
            Image <Gray, byte> mask01w;
            string             mask01wFn = DoWholeTissueSegmentation(img01, out mask01w, "\\mask01w.png");

            Image <Gray, byte> mask02w;
            string             mask02wFn = DoWholeTissueSegmentation(img02, out mask02w, "\\mask02w.png");

            sitk.LabelOverlapMeasuresImageFilter overlapFilter = null;
            if (isInnerSeg)
            {
                string mask01iFn = DoInnerTissueSegmentation(img01, mask01w, "\\mask01i.png");
                string mask02iFn = DoInnerTissueSegmentation(img02, mask02w, "\\mask02i.png");

                overlapFilter = GetOverlapImageFilter(mask01iFn, mask02iFn);

                DeleteFile(mask01iFn);
                DeleteFile(mask02iFn);
            }
            else
            {
                overlapFilter = GetOverlapImageFilter(mask01wFn, mask02wFn);
            }

            if (overlapFilter != null)
            {
                double diceCoef      = overlapFilter.GetDiceCoefficient();
                double falseNegative = overlapFilter.GetFalseNegativeError();
                double falsePositive = overlapFilter.GetFalsePositiveError();
                double jaccard       = overlapFilter.GetJaccardCoefficient();
                double meanOverlap   = overlapFilter.GetMeanOverlap();
                double unionOverlap  = overlapFilter.GetUnionOverlap();

                labelDice.Text         = diceCoef.ToString("0.###");
                labelJacc.Text         = jaccard.ToString("0.###");
                labelfalseNegPos.Text  = string.Format("{0} / {1}", falseNegative.ToString("0.###"), falsePositive.ToString("0.###"));
                labelMeanOverlap.Text  = meanOverlap.ToString("0.###");
                labelUnionOverlap.Text = unionOverlap.ToString("0.###");
            }

            DeleteFile(mask01wFn);
            DeleteFile(mask02wFn);

            Cursor.Current = Cursors.Default;
        }
Esempio n. 3
0
        public SegParamsWholeTissueForm(List <string> imageFilnames, SegmentationParameters parameters)
        {
            InitializeComponent();

            this.segmentationParameters = parameters;
            this.filenames    = imageFilnames;
            this.selectedFile = imageFilnames.FirstOrDefault();
            this.image        = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(this.selectedFile);

            InitializeButtons();
        }
        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);
        }
Esempio n. 5
0
        private void buttonNextSlice_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            int index = filenames.IndexOf(selectedFile) + 1;

            selectedFile = filenames.ElementAt(index);
            image.Dispose();
            image = ReadWriteUtils.ReadOpenCVImageFromFile <Bgr, byte>(selectedFile);

            ReloadForm();

            buttonPreviousSlice.Enabled = index > 0;
            buttonNextSlice.Enabled     = index < filenames.Count - 1;
            Cursor.Current = Cursors.Default;
        }
        /// <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);
        }