Ejemplo n.º 1
0
        public HRegion Extract(HImage image)
        {
            var domain        = image.GetDomain();
            var offsetRow1    = domain.GetRow1();
            var offsetColumn1 = domain.GetColumn1();
            var croppedImage  = image.CropDomain();

            var    swThresholdImageFilter = new NotifyStopwatch("DynThresholdCroppedRegionExtractor.ThresholdImageFilter");
            HImage thresholdImage         = ThresholdImageFilter.Process(croppedImage);

            swThresholdImageFilter.Dispose();

            var     swDynThreshold = new NotifyStopwatch("DynThresholdCroppedRegionExtractor.DynThreshold");
            HRegion region         = croppedImage.DynThreshold(
                thresholdImage,
                Offset,
                LightDark.ToHalconString());

            swDynThreshold.Dispose();

            var movedRegion = region.MoveRegion(offsetRow1, offsetColumn1);

            croppedImage.Dispose();
            thresholdImage.Dispose();
            region.Dispose();

            return(movedRegion);
        }
Ejemplo n.º 2
0
        public HImage Process(HImage image)
        {
//            image.WriteImage("tiff", 0, @"B:\Test_Ori");

            var preprocessImage = PreprocessFilter.Process(image);
//            preprocessImage.WriteImage("tiff", 0, @"B:\Test_preprocessImage");

            var thresholdImage = ThresholdImageFilter.Process(preprocessImage);
//            thresholdImage.WriteImage("tiff", 0, @"B:\Test_thresholdImage");

            HRegion region = preprocessImage.DynThreshold(
                thresholdImage,
                Offset,
                LightDark.ToHalconString());
            var complement = region.Complement();

            thresholdImage.OverpaintRegion(region, (double)ForegroundGray, "fill");
            thresholdImage.OverpaintRegion(complement, (double)BackgroundGray, "fill");
//            thresholdImage.WriteImage("tiff", 0, @"B:\Test_OverpaintRegion");

            region.Dispose();
            complement.Dispose();
            preprocessImage.Dispose();

            return(thresholdImage);
        }
Ejemplo n.º 3
0
        public HRegion Extract(HImage image)
        {
            HImage preprocessImage;

            if (PreprocessFilter != null)
            {
                preprocessImage = PreprocessFilter.Process(image);
            }
            else
            {
                preprocessImage = image;
            }

            HImage thresholdImage;

            if (SeparateFilter)
            {
                var swThresholdImageFilter = new NotifyStopwatch("DynThresholdRegionExtractor.ThresholdImageFilter");
                thresholdImage = ThresholdImageFilter.Process(image);
                swThresholdImageFilter.Dispose();
            }
            else
            {
                var swThresholdImageFilter = new NotifyStopwatch("DynThresholdRegionExtractor.ThresholdImageFilter");
                thresholdImage = ThresholdImageFilter.Process(preprocessImage);
                swThresholdImageFilter.Dispose();
            }

            var     swDynThreshold = new NotifyStopwatch("DynThresholdRegionExtractor.DynThreshold");
            HRegion region         = preprocessImage.DynThreshold(
                thresholdImage,
                Offset,
                LightDark.ToHalconString());

            swDynThreshold.Dispose();

            preprocessImage.Dispose();
            thresholdImage.Dispose();

            return(region);
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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);
        }