/// <summary>
        /// Get the coefficient map of inner structures of tissue for the transform rigidity penalty term.
        /// </summary>
        /// <param name="filename">image filename</param>
        /// <returns>return coefficient map filename</returns>
        private string GetInnerStructureSegmentationsAsCoefficientMap(string filename)
        {
            InnerTissueSegmentation innerSegImage = GetInnerStructureSegmentation(filename);

            string filenameCoefficientMap = ReadWriteUtils.GetOutputDirectory(_parameters, _parameters.Iteration) + Constants.cCoefficientFilename;

            ReadWriteUtils.WriteUMatToFile(filenameCoefficientMap, innerSegImage.GetOutput().FirstOrDefault());
            innerSegImage.Dispose();

            // rescale image
            sitk.Image           img        = ReadWriteUtils.ReadITKImageFromFile(filenameCoefficientMap);
            sitk.CastImageFilter castFilter = new sitk.CastImageFilter();
            castFilter.SetOutputPixelType(sitk.PixelIDValueEnum.sitkFloat32);
            img = castFilter.Execute(img);
            sitk.RescaleIntensityImageFilter filter = new sitk.RescaleIntensityImageFilter();
            filter.SetOutputMinimum(0.0);
            filter.SetOutputMaximum(1.0);
            sitk.Image coefficientMap = filter.Execute(img);

            // save as mhd
            filenameCoefficientMap = ReadWriteUtils.GetOutputDirectory(_parameters, _parameters.Iteration) + Constants.cCoefficientFilename;
            ReadWriteUtils.WriteSitkImage(coefficientMap, filenameCoefficientMap);
            coefficientMap.Dispose();
            return(filenameCoefficientMap);
        }
Example #2
0
        public static sitk.Image BinaryThinning(sitk.Image inputImage)
        {
            sitk.VectorIndexSelectionCastImageFilter vectorIndexSelectionCastImageFilter = new sitk.VectorIndexSelectionCastImageFilter();
            sitk.CastImageFilter castImageFilter = new sitk.CastImageFilter();
            sitk.Image           image           = vectorIndexSelectionCastImageFilter.Execute(inputImage, 0, castImageFilter.GetOutputPixelType());

            sitk.BinaryThresholdImageFilter binaryThresholdImageFilter = new sitk.BinaryThresholdImageFilter();
            binaryThresholdImageFilter.SetInsideValue(0);
            binaryThresholdImageFilter.SetOutsideValue(255);
            binaryThresholdImageFilter.SetLowerThreshold(0);
            binaryThresholdImageFilter.SetUpperThreshold(100);
            sitk.Image binaryThresholdImage = binaryThresholdImageFilter.Execute(image);

            sitk.BinaryThinningImageFilter binaryThinningImageFilter = new sitk.BinaryThinningImageFilter();
            sitk.Image binaryThinningImage = binaryThinningImageFilter.Execute(binaryThresholdImage);

            sitk.RescaleIntensityImageFilter rescaleIntensityImageFilter = new sitk.RescaleIntensityImageFilter();
            rescaleIntensityImageFilter.SetOutputMinimum(0);
            rescaleIntensityImageFilter.SetOutputMaximum(255);
            sitk.Image rescaleIntensityImage = rescaleIntensityImageFilter.Execute(binaryThinningImage);

            return(rescaleIntensityImage);
        }