From: srit Date: Wed, 15 Sep 2010 14:51:26 +0000 (+0000) Subject: Do pad before connecting components X-Git-Tag: v1.2.0~392 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a55c4b8805a34466d29bdcdb24b4f107b2515e23;p=clitk.git Do pad before connecting components --- diff --git a/segmentation/clitkMotionMaskGenericFilter.txx b/segmentation/clitkMotionMaskGenericFilter.txx index 95747df..d2de0d4 100755 --- a/segmentation/clitkMotionMaskGenericFilter.txx +++ b/segmentation/clitkMotionMaskGenericFilter.txx @@ -97,6 +97,25 @@ MotionMaskGenericFilter::GetAirImage(typename itk::Image:: if (m_Verbose) std::cout<<"Reading the air feature image..."<Update(); air=featureReader->GetOutput(); + + //--------------------------------- + // Pad + //--------------------------------- + if(m_ArgsInfo.pad_flag) { + typedef itk::ImageRegionIteratorWithIndex IteratorType; + IteratorType it(air, air->GetLargestPossibleRegion()); + typename InternalImageType::IndexType index; + while(!it.IsAtEnd()) { + index=it.GetIndex(); + for (unsigned int i=0; iGetLargestPossibleRegion().GetIndex()[i] + || index[i]==(unsigned int)air->GetLargestPossibleRegion().GetIndex()[i]+ (unsigned int) air->GetLargestPossibleRegion().GetSize()[i]-1)) + it.Set(1); + } + ++it; + } + } } else { if (m_Verbose) std::cout<<"Extracting the air feature image..."<:: if (m_Verbose) std::cout<<"Binarizing the image using thresholds "<Update(); + air = binarizeFilter->GetOutput(); + + //--------------------------------- + // Pad + //--------------------------------- + if(m_ArgsInfo.pad_flag) { + typedef itk::ImageRegionIteratorWithIndex IteratorType; + IteratorType it(air, air->GetLargestPossibleRegion()); + typename InternalImageType::IndexType index; + while(!it.IsAtEnd()) { + index=it.GetIndex(); + for (unsigned int i=0; iGetLargestPossibleRegion().GetIndex()[i] + || index[i]==(unsigned int)air->GetLargestPossibleRegion().GetIndex()[i]+ (unsigned int) air->GetLargestPossibleRegion().GetSize()[i]-1)) + it.Set(binarizeFilter->GetInsideValue()); + } + ++it; + } + } //--------------------------------- // Remove lungs (in place) //--------------------------------- typedef itk::ImageRegionIterator IteratorType; - IteratorType itAir(binarizeFilter->GetOutput(), binarizeFilter->GetOutput()->GetLargestPossibleRegion()); + IteratorType itAir(air, binarizeFilter->GetOutput()->GetLargestPossibleRegion()); IteratorType itLungs(lungs, binarizeFilter->GetOutput()->GetLargestPossibleRegion()); //lungs padded, used air region itAir.GoToBegin(); itLungs.GoToBegin(); @@ -176,23 +215,6 @@ MotionMaskGenericFilter::GetAirImage(typename itk::Image:: air=mirrorPadImageFilter->GetOutput(); //writeImage(air,"/home/srit/tmp/air.mhd"); - //--------------------------------- - // Pad - //--------------------------------- - if(m_ArgsInfo.pad_flag) { - typedef itk::ImageRegionIteratorWithIndex IteratorType; - IteratorType it(air, air->GetLargestPossibleRegion()); - typename InternalImageType::IndexType index; - while(!it.IsAtEnd()) { - index=it.GetIndex(); - for (unsigned int i=0; iGetLargestPossibleRegion().GetIndex()[i] - || index[i]==(unsigned int)air->GetLargestPossibleRegion().GetIndex()[i]+ (unsigned int) air->GetLargestPossibleRegion().GetSize()[i]-1) - it.Set(0); - ++it; - } - } - return air; }