X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=segmentation%2FclitkMotionMaskGenericFilter.txx;h=543bcdb830f61de6537c5537e7204a59023f3433;hb=6808027e48645d72771bbb0e342e8be47dd0ea92;hp=50d5269d0f427b57128fec149295681bc7dcd417;hpb=551de487436fa3401e42a72ec908e059e6837c4c;p=clitk.git diff --git a/segmentation/clitkMotionMaskGenericFilter.txx b/segmentation/clitkMotionMaskGenericFilter.txx old mode 100755 new mode 100644 index 50d5269..543bcdb --- a/segmentation/clitkMotionMaskGenericFilter.txx +++ b/segmentation/clitkMotionMaskGenericFilter.txx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef clitkMotionMaskGenericFilter_txx #define clitkMotionMaskGenericFilter_txx @@ -97,6 +97,28 @@ 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(); + + //Pad borders of all dimensions but 2 (cranio-caudal) + 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(); + + //Pad borders of all dimensions but 2 (cranio-caudal) + 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(); @@ -174,24 +219,7 @@ MotionMaskGenericFilter::GetAirImage(typename itk::Image:: if (m_Verbose) std::cout<<"Mirroring the entire image along the CC axis..."<Update(); 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; - } - } + //writeImage(air,"/home/srit/tmp/air.mhd"); return air; } @@ -349,6 +377,8 @@ MotionMaskGenericFilter::GetLungsImage(typename itk::Image connectFilter->SetBackgroundValue(0); connectFilter->SetFullyConnected(true); if (m_Verbose) std::cout<<"Labeling the connected components..."<Update(); + if (m_Verbose) std::cout<<"found "<< connectFilter->GetObjectCount() << std::endl; //--------------------------------- // Sort the labels according to size @@ -356,7 +386,7 @@ MotionMaskGenericFilter::GetLungsImage(typename itk::Image typename RelabelFilterType::Pointer relabelFilter=RelabelFilterType::New(); relabelFilter->SetInput(connectFilter->GetOutput()); if (m_Verbose) std::cout<<"Sorting the labels..."< (relabelFilter->GetOutput(), "/home/jef/tmp/labels.mhd"); + // writeImage (relabelFilter->GetOutput(), "/home/vdelmon/tmp/labels.mhd"); //--------------------------------- // Keep the label