]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authorVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Tue, 14 Jun 2011 07:39:28 +0000 (09:39 +0200)
committerVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Tue, 14 Jun 2011 07:39:28 +0000 (09:39 +0200)
segmentation/clitkExtractLung.ggo
segmentation/clitkExtractLungFilter.h
segmentation/clitkExtractLungFilter.txx
segmentation/clitkExtractLungGenericFilter.txx

index 5f53b4d1926312ed855300abe6404180dda82b5c..12dd3e7040823c00e0676c005d95ec63d7522c94 100644 (file)
@@ -61,3 +61,4 @@ section "Step 6 : fill holes"
 option "doNotFillHoles"                -  "Do not fill holes if set"                 flag on
 option "dir"                   d  "Directions (axes) to perform filling (defaults to 2,1,0)"   int multiple no
 
+option "noAutoCrop"    -       "If set : do no crop final mask to BoundingBox"                         flag    off
index 50d553ae41ce9c130d9ba7acfde941354f3d1fd6..fa472ba711db3bff2c7ed8094380fc6b3505936c 100644 (file)
@@ -191,6 +191,11 @@ namespace clitk {
     itkGetConstMacro(FillHolesFlag, bool);
     itkBooleanMacro(FillHolesFlag);
 
+    // Step Auto Crop
+    itkSetMacro(AutoCrop, bool);
+    itkGetConstMacro(AutoCrop, bool);
+    itkBooleanMacro(AutoCrop);
+
   protected:
     ExtractLungFilter();
     virtual ~ExtractLungFilter() {}
@@ -212,6 +217,7 @@ namespace clitk {
     MaskImagePixelType m_BackgroundValue;
     MaskImagePixelType m_ForegroundValue;
     int m_MinimalComponentSize;
+    bool m_AutoCrop;
 
     // Step 1
     InputImagePixelType m_UpperThreshold;
index 67d3f5e641c08bb357a57c0b51fc17805287de45..3a098e9aad5c84bbbe965995ef7200ee974368ab 100644 (file)
@@ -96,6 +96,7 @@ ExtractLungFilter():
   
   // Step 6
   FillHolesFlagOn();
+  AutoCropOn();
 }
 //--------------------------------------------------------------------
 
@@ -311,7 +312,8 @@ GenerateOutputInformation()
   //--------------------------------------------------------------------
   PrintMemory(GetVerboseMemoryFlag(), "before autocropfilter");
   if (m_Seeds.size() != 0) { // if ==0 ->no trachea found
-    trachea = clitk::AutoCrop<MaskImageType>(trachea, GetBackgroundValue());
+    if (GetAutoCrop())
+      trachea = clitk::AutoCrop<MaskImageType>(trachea, GetBackgroundValue());
     StopCurrentStep<MaskImageType>(trachea);  
     PrintMemory(GetVerboseMemoryFlag(), "after delete trachea");
   }
@@ -321,7 +323,8 @@ GenerateOutputInformation()
   //--------------------------------------------------------------------
   StartNewStep("Cropping lung");
   PrintMemory(GetVerboseMemoryFlag(), "Before Autocropfilter");
-  working_mask = clitk::AutoCrop<MaskImageType>(working_mask, GetBackgroundValue());
+  if (GetAutoCrop())
+    working_mask = clitk::AutoCrop<MaskImageType>(working_mask, GetBackgroundValue());
   StopCurrentStep<MaskImageType>(working_mask);
 
   //--------------------------------------------------------------------
@@ -588,7 +591,7 @@ ComputeTracheaVolume()
 
 //--------------------------------------------------------------------
 template <class ImageType>
-void 
+void
 clitk::ExtractLungFilter<ImageType>::
 SearchForTrachea()
 {
@@ -603,8 +606,8 @@ SearchForTrachea()
   double volume = 0.0;
   int skip = GetNumberOfSlicesToSkipBeforeSearchingSeed();
   while (!stop) {
-    stop = SearchForTracheaSeed(skip);
-    if (stop) {
+    stop = true;
+    if (SearchForTracheaSeed(skip)) {
       TracheaRegionGrowing();
       volume = ComputeTracheaVolume()/1000; // assume mm3, so divide by 1000 to get cc
       if (GetWriteStepFlag()) {
@@ -616,7 +619,6 @@ SearchForTrachea()
           if (GetVerboseStepFlag()) {
             std::cout << "\t Found trachea with volume " << volume << " cc." << std::endl;
           }
-          stop = true; 
         }
         else {
           if (GetVerboseStepFlag()) {
@@ -629,6 +631,11 @@ SearchForTrachea()
           // empty the list of seed
           m_Seeds.clear();
         }
+        if (skip > 0.5 * working_input->GetLargestPossibleRegion().GetSize()[2]) {
+          // we want to skip more than a half of the image, it is probably a bug
+          std::cerr << "2 : Number of slices to skip to find trachea too high = " << skip << std::endl;
+          stop = true;
+        }
       }
       else {
         stop = true;
index e103310e1efe7d89c455bc28003386afd88a1dc5..2dd396fb3a2498fb0a5ff15e3dc01a2bf6af6db8 100644 (file)
@@ -102,6 +102,7 @@ SetOptionsFromArgsInfoToFilter(FilterType * f)
   
   f->SetOpenCloseFlag(mArgsInfo.openclose_flag);
   f->SetOpenCloseRadius(mArgsInfo.opencloseRadius_arg);
+  f->SetAutoCrop(!mArgsInfo.noAutoCrop_flag);
   
   if (mArgsInfo.doNotFillHoles_given)
     f->SetFillHolesFlag(false);