コード例 #1
0
        public itk.simple.Image SegmetacjaSledziony(itk.simple.Image image)
        {
            itk.simple.MorphologicalGradientImageFilter gradientFilter = new MorphologicalGradientImageFilter();
            gradientFilter.SetKernelType(KernelEnum.sitkCross);
            gradientFilter.SetKernelRadius(1);
            itk.simple.Image gradientImage = gradientFilter.Execute(image);
            
            itk.simple.SigmoidImageFilter sigmoidFilter = new SigmoidImageFilter();
            sigmoidFilter.SetOutputMinimum(0);
            sigmoidFilter.SetOutputMaximum(1);
            sigmoidFilter.SetAlpha(1.5);
            sigmoidFilter.SetBeta(100);
            itk.simple.Image sigmoidImage = sigmoidFilter.Execute(gradientImage);
          
            itk.simple.BinaryThresholdImageFilter threshFilter = new BinaryThresholdImageFilter();
            threshFilter.SetLowerThreshold(100);
            threshFilter.SetUpperThreshold(180);
            threshFilter.SetOutsideValue(0);
            threshFilter.SetInsideValue(1);
            itk.simple.Image threshImage = threshFilter.Execute(image);
            itk.simple.CastImageFilter castThresh = new CastImageFilter();
            castThresh.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkInt16);
            itk.simple.Image castThreshImage = castThresh.Execute(threshImage);

            itk.simple.SubtractImageFilter substractFilter = new SubtractImageFilter();
            itk.simple.Image substractImage = substractFilter.Execute(castThreshImage, sigmoidImage);

            itk.simple.ThresholdImageFilter threshFilter2 = new ThresholdImageFilter();
            threshFilter2.SetLower(0);
            threshFilter2.SetUpper(0);
            threshFilter2.SetOutsideValue(1);
            itk.simple.Image threshImage2 = threshFilter2.Execute(substractImage);

            itk.simple.BinaryErodeImageFilter erodeFilter = new BinaryErodeImageFilter();
            erodeFilter.SetForegroundValue(1);
            erodeFilter.SetBackgroundValue(0);
            erodeFilter.SetKernelType(itk.simple.KernelEnum.sitkCross);
            erodeFilter.SetKernelRadius(5);
            itk.simple.Image erodeImage = erodeFilter.Execute(threshImage2);

            itk.simple.ConnectedComponentImageFilter connFilter = new ConnectedComponentImageFilter();
            connFilter.SetFullyConnected(true);
            itk.simple.Image connImage = connFilter.Execute(erodeImage);

            itk.simple.RelabelComponentImageFilter relabelFilter = new RelabelComponentImageFilter();
            relabelFilter.SetMinimumObjectSize(5000);
            itk.simple.Image relabelImage = relabelFilter.Execute(connImage);

            itk.simple.BinaryThresholdImageFilter threshFilter3 = new BinaryThresholdImageFilter();
            threshFilter3.SetInsideValue(1);
            threshFilter3.SetOutsideValue(0);
            threshFilter3.SetLowerThreshold(1);
            threshFilter3.SetUpperThreshold(1);
            itk.simple.Image threshImage3 = threshFilter3.Execute(relabelImage);

            itk.simple.DilateObjectMorphologyImageFilter closeReconstructFilter = new DilateObjectMorphologyImageFilter();
            closeReconstructFilter.SetKernelType(itk.simple.KernelEnum.sitkCross);
            closeReconstructFilter.SetKernelRadius(5);
            itk.simple.Image closeReconstructImage = closeReconstructFilter.Execute(threshImage3);
            itk.simple.ImageFileWriter writer = new ImageFileWriter();
            writer.SetFileName("SegmentujSledzione.dcm");
            writer.Execute(closeReconstructImage);

            return closeReconstructImage;
        }
コード例 #2
0
        public itk.simple.Image SegmetacjaSledziony(itk.simple.Image image)
        {
            itk.simple.MorphologicalGradientImageFilter gradientFilter = new MorphologicalGradientImageFilter();
            gradientFilter.SetKernelType(KernelEnum.sitkCross);
            gradientFilter.SetKernelRadius(1);
            itk.simple.Image gradientImage = gradientFilter.Execute(image);

            itk.simple.SigmoidImageFilter sigmoidFilter = new SigmoidImageFilter();
            sigmoidFilter.SetOutputMinimum(0);
            sigmoidFilter.SetOutputMaximum(1);
            sigmoidFilter.SetAlpha(1.5);
            sigmoidFilter.SetBeta(100);
            itk.simple.Image sigmoidImage = sigmoidFilter.Execute(gradientImage);

            itk.simple.BinaryThresholdImageFilter threshFilter = new BinaryThresholdImageFilter();
            threshFilter.SetLowerThreshold(100);
            threshFilter.SetUpperThreshold(180);
            threshFilter.SetOutsideValue(0);
            threshFilter.SetInsideValue(1);
            itk.simple.Image           threshImage = threshFilter.Execute(image);
            itk.simple.CastImageFilter castThresh  = new CastImageFilter();
            castThresh.SetOutputPixelType(itk.simple.PixelIDValueEnum.sitkInt16);
            itk.simple.Image castThreshImage = castThresh.Execute(threshImage);

            itk.simple.SubtractImageFilter substractFilter = new SubtractImageFilter();
            itk.simple.Image substractImage = substractFilter.Execute(castThreshImage, sigmoidImage);

            itk.simple.ThresholdImageFilter threshFilter2 = new ThresholdImageFilter();
            threshFilter2.SetLower(0);
            threshFilter2.SetUpper(0);
            threshFilter2.SetOutsideValue(1);
            itk.simple.Image threshImage2 = threshFilter2.Execute(substractImage);

            itk.simple.BinaryErodeImageFilter erodeFilter = new BinaryErodeImageFilter();
            erodeFilter.SetForegroundValue(1);
            erodeFilter.SetBackgroundValue(0);
            erodeFilter.SetKernelType(itk.simple.KernelEnum.sitkCross);
            erodeFilter.SetKernelRadius(5);
            itk.simple.Image erodeImage = erodeFilter.Execute(threshImage2);

            itk.simple.ConnectedComponentImageFilter connFilter = new ConnectedComponentImageFilter();
            connFilter.SetFullyConnected(true);
            itk.simple.Image connImage = connFilter.Execute(erodeImage);

            itk.simple.RelabelComponentImageFilter relabelFilter = new RelabelComponentImageFilter();
            relabelFilter.SetMinimumObjectSize(5000);
            itk.simple.Image relabelImage = relabelFilter.Execute(connImage);

            itk.simple.BinaryThresholdImageFilter threshFilter3 = new BinaryThresholdImageFilter();
            threshFilter3.SetInsideValue(1);
            threshFilter3.SetOutsideValue(0);
            threshFilter3.SetLowerThreshold(1);
            threshFilter3.SetUpperThreshold(1);
            itk.simple.Image threshImage3 = threshFilter3.Execute(relabelImage);

            itk.simple.DilateObjectMorphologyImageFilter closeReconstructFilter = new DilateObjectMorphologyImageFilter();
            closeReconstructFilter.SetKernelType(itk.simple.KernelEnum.sitkCross);
            closeReconstructFilter.SetKernelRadius(5);
            itk.simple.Image           closeReconstructImage = closeReconstructFilter.Execute(threshImage3);
            itk.simple.ImageFileWriter writer = new ImageFileWriter();
            writer.SetFileName("SegmentujSledzione.dcm");
            writer.Execute(closeReconstructImage);

            return(closeReconstructImage);
        }