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
- 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
if (m_Verbose) std::cout<<"Reading the air feature image..."<<std::endl;
featureReader->Update();
air=featureReader->GetOutput();
+
+ //---------------------------------
+ // Pad
+ //---------------------------------
+ if(m_ArgsInfo.pad_flag) {
+ typedef itk::ImageRegionIteratorWithIndex<InternalImageType> 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; i<Dimension; i++){
+ if(i==2)
+ continue;
+ if(index[i]==air->GetLargestPossibleRegion().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..."<<std::endl;
//---------------------------------
if (m_Verbose) std::cout<<"Binarizing the image using thresholds "<<m_ArgsInfo.lowerThresholdAir_arg
<<", "<<m_ArgsInfo.upperThresholdAir_arg<<"..."<<std::endl;
binarizeFilter->Update();
+ air = binarizeFilter->GetOutput();
+
+ //---------------------------------
+ // Pad
+ //---------------------------------
+ if(m_ArgsInfo.pad_flag) {
+ typedef itk::ImageRegionIteratorWithIndex<InternalImageType> 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; i<Dimension; i++){
+ if(i==2)
+ continue;
+ if(index[i]==air->GetLargestPossibleRegion().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<InternalImageType> 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();
if (m_Verbose) std::cout<<"Mirroring the entire image along the CC axis..."<<std::endl;
mirrorPadImageFilter->Update();
air=mirrorPadImageFilter->GetOutput();
- writeImage<InternalImageType>(air,"/home/srit/tmp/air.mhd");
-
- //---------------------------------
- // Pad
- //---------------------------------
- if(m_ArgsInfo.pad_flag) {
- typedef itk::ImageRegionIteratorWithIndex<InternalImageType> IteratorType;
- IteratorType it(air, air->GetLargestPossibleRegion());
- typename InternalImageType::IndexType index;
- while(!it.IsAtEnd()) {
- index=it.GetIndex();
- for (unsigned int i=0; i<Dimension; i++)
- if(index[i]==air->GetLargestPossibleRegion().GetIndex()[i]
- || index[i]==(unsigned int)air->GetLargestPossibleRegion().GetIndex()[i]+ (unsigned int) air->GetLargestPossibleRegion().GetSize()[i]-1)
- it.Set(0);
- ++it;
- }
- }
+ //writeImage<InternalImageType>(air,"/home/srit/tmp/air.mhd");
return air;
}
connectFilter->SetBackgroundValue(0);
connectFilter->SetFullyConnected(true);
if (m_Verbose) std::cout<<"Labeling the connected components..."<<std::endl;
+ connectFilter->Update();
+ if (m_Verbose) std::cout<<"found "<< connectFilter->GetObjectCount() << std::endl;
//---------------------------------
// Sort the labels according to size
typename RelabelFilterType::Pointer relabelFilter=RelabelFilterType::New();
relabelFilter->SetInput(connectFilter->GetOutput());
if (m_Verbose) std::cout<<"Sorting the labels..."<<std::endl;
- // writeImage<InternalImageType> (relabelFilter->GetOutput(), "/home/jef/tmp/labels.mhd");
+ // writeImage<InternalImageType> (relabelFilter->GetOutput(), "/home/vdelmon/tmp/labels.mhd");
//---------------------------------
// Keep the label