]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of /home/dsarrut/clitk3.server
authormpech <maxime.pech@insa-lyon.fr>
Tue, 14 Jun 2011 11:27:45 +0000 (13:27 +0200)
committermpech <maxime.pech@insa-lyon.fr>
Tue, 14 Jun 2011 11:27:45 +0000 (13:27 +0200)
25 files changed:
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx
segmentation/CMakeLists.txt
segmentation/clitkBool.cxx [new file with mode: 0644]
segmentation/clitkBool.ggo [new file with mode: 0644]
segmentation/clitkBooleanOperatorLabelImageGenericFilter.h [new file with mode: 0644]
segmentation/clitkBooleanOperatorLabelImageGenericFilter.txx [new file with mode: 0644]
segmentation/clitkExtractLung.ggo
segmentation/clitkExtractLungFilter.h
segmentation/clitkExtractLungFilter.txx
segmentation/clitkExtractLungGenericFilter.txx
tools/clitkCropImageGenericFilter.cxx
tools/clitkImageArithm.ggo
tools/clitkImageArithmGenericFilter.txx
vv/CMakeLists.txt
vv/icons/identity.png [new file with mode: 0644]
vv/vvIcons.qrc
vv/vvInfoPanel.cxx
vv/vvInfoPanel.h
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvMainWindow.txx [deleted file]
vv/vvSlicer.cxx
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h

index 4d7129821eabf8aeac167f0b5699dcf878e372da..7ae1c77515679e5d976982268a7cab7acb2d4369 100644 (file)
@@ -204,6 +204,11 @@ namespace clitk {
 
 
   //--------------------------------------------------------------------
+  template<class ImageType, class LabelType>
+  typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+  ComputeLabelMap(const ImageType * image, 
+                  typename ImageType::PixelType BG,                   
+                  bool computePerimeterFlag=false);
   template<class ImageType>
   void
   ComputeCentroids(const ImageType * image, 
@@ -407,6 +412,13 @@ namespace clitk {
   //--------------------------------------------------------------------
   
 
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  typename ImageType::Pointer
+  Clone(const ImageType * input);
+  //--------------------------------------------------------------------
+  
+
 }
 
 #include "clitkSegmentationUtils.txx"
index f7b897e1f7805ffd4067af65af523ab9a3e4dbdc..4990b247c2b85dac1e342b77dc64901c80c553f6 100644 (file)
@@ -33,6 +33,7 @@
 #include <itkConstantPadImageFilter.h>
 #include <itkImageSliceIteratorWithIndex.h>
 #include <itkBinaryMorphologicalOpeningImageFilter.h>
+#include <itkImageDuplicator.h>
 
 namespace clitk {
 
@@ -519,6 +520,30 @@ namespace clitk {
   //--------------------------------------------------------------------
 
 
+  //--------------------------------------------------------------------
+  template<class ImageType, class LabelType>
+  typename itk::LabelMap< itk::ShapeLabelObject<LabelType, ImageType::ImageDimension> >::Pointer
+  ComputeLabelMap(const ImageType * image, 
+                  typename ImageType::PixelType BG, 
+                  bool computePerimeterFlag) 
+  {
+    static const unsigned int Dim = ImageType::ImageDimension;
+    typedef itk::ShapeLabelObject< LabelType, Dim > LabelObjectType;
+    typedef itk::LabelMap< LabelObjectType > LabelMapType;
+    typedef itk::LabelImageToLabelMapFilter<ImageType, LabelMapType> ImageToMapFilterType;
+    typename ImageToMapFilterType::Pointer imageToLabelFilter = ImageToMapFilterType::New(); 
+    typedef itk::ShapeLabelMapFilter<LabelMapType, ImageType> ShapeFilterType; 
+    typename ShapeFilterType::Pointer statFilter = ShapeFilterType::New();
+    imageToLabelFilter->SetBackgroundValue(BG);
+    imageToLabelFilter->SetInput(image);
+    statFilter->SetInput(imageToLabelFilter->GetOutput());
+    statFilter->SetComputePerimeter(computePerimeterFlag);
+    statFilter->Update();
+    return statFilter->GetOutput();
+  }
+  //--------------------------------------------------------------------
+
+
   //--------------------------------------------------------------------
   template<class ImageType>
   void
@@ -1076,5 +1101,18 @@ namespace clitk {
   //--------------------------------------------------------------------
 
 
+  //--------------------------------------------------------------------
+  template<class ImageType>
+  typename ImageType::Pointer
+  Clone(const ImageType * input) {
+    typedef itk::ImageDuplicator<ImageType> DuplicatorType;
+    typename DuplicatorType::Pointer duplicator = DuplicatorType::New();
+    duplicator->SetInputImage(input);
+    duplicator->Update();
+    return duplicator->GetOutput();
+  }
+  //--------------------------------------------------------------------
+
+
 } // end of namespace
 
index 0495a8f5668dbd3ee1828dfa4cb52bfe291b6734..6f8e2ef03e327ac2587a55e7ae43da234a5ad1c3 100644 (file)
@@ -39,17 +39,21 @@ IF(CLITK_BUILD_SEGMENTATION)
     ADD_EXECUTABLE(clitkExtractBones clitkExtractBones.cxx ${clitkExtractBones_GGO_C})
     TARGET_LINK_LIBRARIES(clitkExtractBones clitkCommon ${ITK_LIBRARIES} clitkSegmentationGgoLib)
 
+    WRAP_GGO(clitkBool_GGO_C clitkBool.ggo)
+    ADD_EXECUTABLE(clitkBool clitkBool.cxx ${clitkBool_GGO_C})
+    TARGET_LINK_LIBRARIES(clitkBool clitkCommon ${ITK_LIBRARIES} clitkSegmentationGgoLib)
+
     WRAP_GGO(clitkExtractMediastinum_GGO_C clitkExtractMediastinum.ggo)
     ADD_EXECUTABLE(clitkExtractMediastinum clitkExtractMediastinum.cxx ${clitkExtractMediastinum_GGO_C})
     TARGET_LINK_LIBRARIES(clitkExtractMediastinum clitkCommon clitkSegmentationGgoLib ${ITK_LIBRARIES})
 
-    WRAP_GGO(clitkExtractLymphStations_GGO_C clitkExtractLymphStations.ggo)
-    ADD_EXECUTABLE(clitkExtractLymphStations clitkExtractLymphStations.cxx clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx ${clitkExtractLymphStations_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkExtractLymphStations clitkSegmentationGgoLib clitkCommon vtkHybrid)
+    WRAP_GGO(clitkExtractLymphStations_GGO_C clitkExtractLymphStations.ggo)
+    ADD_EXECUTABLE(clitkExtractLymphStations clitkExtractLymphStations.cxx clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx ${clitkExtractLymphStations_GGO_C})
+    TARGET_LINK_LIBRARIES(clitkExtractLymphStations clitkSegmentationGgoLib clitkCommon vtkHybrid)
 
-    WRAP_GGO(clitkExtractMediastinalVessels_GGO_C clitkExtractMediastinalVessels.ggo)
-    ADD_EXECUTABLE(clitkExtractMediastinalVessels clitkExtractMediastinalVessels.cxx clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx ${clitkExtractMediastinalVessels_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkExtractMediastinalVessels clitkSegmentationGgoLib clitkCommon vtkHybrid)
+    WRAP_GGO(clitkExtractMediastinalVessels_GGO_C clitkExtractMediastinalVessels.ggo)
+    ADD_EXECUTABLE(clitkExtractMediastinalVessels clitkExtractMediastinalVessels.cxx clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx ${clitkExtractMediastinalVessels_GGO_C})
+    TARGET_LINK_LIBRARIES(clitkExtractMediastinalVessels clitkSegmentationGgoLib clitkCommon vtkHybrid)
 
     WRAP_GGO(clitkMorphoMath_GGO_C clitkMorphoMath.ggo)
     ADD_EXECUTABLE(clitkMorphoMath clitkMorphoMath.cxx ${clitkMorphoMath_GGO_C})
diff --git a/segmentation/clitkBool.cxx b/segmentation/clitkBool.cxx
new file mode 100644 (file)
index 0000000..dbb313c
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to:
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
+
+// clitk
+#include "clitkBool_ggo.h"
+#include "clitkBooleanOperatorLabelImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkBool, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::BooleanOperatorLabelImageGenericFilter<args_info_clitkBool> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  
+  try {
+    filter->Update();
+  } catch(std::runtime_error e) {
+    std::cout << e.what() << std::endl;
+  }
+
+  return EXIT_SUCCESS;
+} // This is the end, my friend
+//--------------------------------------------------------------------
diff --git a/segmentation/clitkBool.ggo b/segmentation/clitkBool.ggo
new file mode 100644 (file)
index 0000000..ede9646
--- /dev/null
@@ -0,0 +1,14 @@
+#File clitkExtractMediastinalVessels.ggo
+package "clitkExtractMediastinalVessels"
+version "1.0"
+purpose "Extract MediastinalVessels"
+
+option "config"                -  "Config file"                  string        no
+option "imagetypes"     -  "Display allowed image types"  flag          off
+option "verbose"        v  "Verbose"                     flag          off
+
+option "input"         i       "Input mask 1"               string     yes
+option "input2"        j       "Input mask 2"               string     yes
+option "output"        o       "Output filename"            string     yes
+
+option "type"          t       "Bool type : "               int default="1" no
diff --git a/segmentation/clitkBooleanOperatorLabelImageGenericFilter.h b/segmentation/clitkBooleanOperatorLabelImageGenericFilter.h
new file mode 100644 (file)
index 0000000..acd69ff
--- /dev/null
@@ -0,0 +1,80 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+======================================================================-====*/
+
+#ifndef CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
+#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
+
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkBooleanOperatorLabelImageFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk 
+{
+  
+  template<class ArgsInfoType>
+  class ITK_EXPORT BooleanOperatorLabelImageGenericFilter: 
+    public ImageToImageGenericFilter<BooleanOperatorLabelImageGenericFilter<ArgsInfoType> >
+  {
+    
+  public:
+    //--------------------------------------------------------------------
+    BooleanOperatorLabelImageGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef ImageToImageGenericFilter<BooleanOperatorLabelImageGenericFilter<ArgsInfoType> > Superclass;
+    typedef BooleanOperatorLabelImageGenericFilter Self;
+    typedef itk::SmartPointer<Self>           Pointer;
+    typedef itk::SmartPointer<const Self>     ConstPointer;
+
+    //--------------------------------------------------------------------
+    itkNewMacro(Self);  
+    itkTypeMacro(BooleanOperatorLabelImageGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    // Options for the GenericFilter
+    void SetArgsInfo(const ArgsInfoType & a);
+
+    //--------------------------------------------------------------------
+    // Options for the Filter
+    template<class FilterType> 
+    void SetOptionsFromArgsInfoToFilter(FilterType * f) ;
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class ImageType>  
+    void UpdateWithInputImageType();
+
+  protected:
+    template<unsigned int Dim> void InitializeImageType();
+    ArgsInfoType mArgsInfo;
+    
+  private:
+    BooleanOperatorLabelImageGenericFilter(const Self&); //purposely not implemented
+    void operator=(const Self&); //purposely not implemented
+    
+  }; // end class
+  //--------------------------------------------------------------------
+    
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBooleanOperatorLabelImageGenericFilter.txx"
+#endif
+
+#endif // #define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_H
diff --git a/segmentation/clitkBooleanOperatorLabelImageGenericFilter.txx b/segmentation/clitkBooleanOperatorLabelImageGenericFilter.txx
new file mode 100644 (file)
index 0000000..0c07b67
--- /dev/null
@@ -0,0 +1,104 @@
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
+
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
+
+  It is distributed under dual licence
+
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+  ======================================================================-====*/
+
+#ifndef CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_TXX
+#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_TXX
+
+#include "clitkImageCommon.h"
+  
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::BooleanOperatorLabelImageGenericFilter():
+  ImageToImageGenericFilter<Self>("BooleanOperatorLabelImage") 
+{
+  // Default values
+  cmdline_parser_clitkBool_init(&mArgsInfo);
+  InitializeImageType<3>(); // Only for 3D images
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<unsigned int Dim>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::InitializeImageType() 
+{  
+  ADD_IMAGE_TYPE(Dim, uchar); // Can add float later
+}
+//--------------------------------------------------------------------
+  
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a) 
+{
+  mArgsInfo=a;
+  SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+  if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
+  if (mArgsInfo.input2_given) AddInputFilename(mArgsInfo.input2_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class FilterType>
+void 
+clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::
+SetOptionsFromArgsInfoToFilter(FilterType * f)
+{
+  // Operation type
+  f->SetOperationType(typename FilterType::OperationTypeEnumeration(mArgsInfo.type_arg));
+  // Output filename
+  this->AddOutputFilename(mArgsInfo.output_arg);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class ArgsInfoType>
+template<class ImageType>
+void clitk::BooleanOperatorLabelImageGenericFilter<ArgsInfoType>::UpdateWithInputImageType() 
+{ 
+  // Reading input
+  typename ImageType::Pointer input1 = this->template GetInput<ImageType>(0);
+  typename ImageType::Pointer input2 = this->template GetInput<ImageType>(1);
+
+  // Create filter
+  typedef clitk::BooleanOperatorLabelImageFilter<ImageType> FilterType;
+  typename FilterType::Pointer filter = FilterType::New();
+    
+  // Set global Options 
+  filter->SetInput1(input1);
+  filter->SetInput2(input2);
+  SetOptionsFromArgsInfoToFilter<FilterType>(filter);
+
+  // Go !
+  filter->Update();
+
+  // Write/Save results
+  typename ImageType::Pointer output = filter->GetOutput();
+  this->template SetNextOutput<ImageType>(output); 
+}
+//--------------------------------------------------------------------
+
+#endif //#define CLITKBOOLEANOPERATORLABELIMAGEGENERICFILTER_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..0954c2a3de46a11249c21237b9644e9a4a123404 100644 (file)
@@ -37,6 +37,7 @@
 #include "itkImageIteratorWithIndex.h"
 #include "itkBinaryMorphologicalOpeningImageFilter.h"
 #include "itkBinaryMorphologicalClosingImageFilter.h"
+#include "itkConstantPadImageFilter.h"
 
 //--------------------------------------------------------------------
 template <class ImageType>
@@ -96,6 +97,7 @@ ExtractLungFilter():
   
   // Step 6
   FillHolesFlagOn();
+  AutoCropOn();
 }
 //--------------------------------------------------------------------
 
@@ -160,6 +162,22 @@ GenerateOutputInformation()
   StartNewStep("Set background to initial image");
   working_input = SetBackground<ImageType, MaskImageType>
     (working_input, patient, GetPatientMaskBackgroundValue(), -1000, true);
+
+  // Pad images with air to prevent patient touching the image border
+  static const unsigned int Dim = ImageType::ImageDimension;
+  typedef itk::ConstantPadImageFilter<ImageType, ImageType> PadFilterType;
+  typename PadFilterType::Pointer padFilter = PadFilterType::New();
+  padFilter->SetInput(working_input);
+  padFilter->SetConstant(-1000);
+  typename ImageType::SizeType bounds;
+  for (unsigned i = 0; i < Dim - 1; ++i)
+    bounds[i] = 1;
+  bounds[Dim - 1] = 0;
+  padFilter->SetPadLowerBound(bounds);
+  padFilter->SetPadUpperBound(bounds);
+  padFilter->Update();
+  working_input = padFilter->GetOutput();
+
   StopCurrentStep<ImageType>(working_input);
   PrintMemory(GetVerboseMemoryFlag(), "After set bg"); // OK, additional mem = 0
 
@@ -311,7 +329,19 @@ 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());
+    else
+    {
+      // Remove Padding region
+      typedef itk::CropImageFilter<MaskImageType, MaskImageType> CropFilterType;
+      typename CropFilterType::Pointer cropFilter = CropFilterType::New();
+      cropFilter->SetInput(trachea);
+      cropFilter->SetLowerBoundaryCropSize(bounds);
+      cropFilter->SetUpperBoundaryCropSize(bounds);
+      cropFilter->Update();
+      trachea = cropFilter->GetOutput();
+    }
     StopCurrentStep<MaskImageType>(trachea);  
     PrintMemory(GetVerboseMemoryFlag(), "after delete trachea");
   }
@@ -321,7 +351,19 @@ 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());
+  else
+  {
+    // Remove Padding region
+    typedef itk::CropImageFilter<MaskImageType, MaskImageType> CropFilterType;
+    typename CropFilterType::Pointer cropFilter = CropFilterType::New();
+    cropFilter->SetInput(working_mask);
+    cropFilter->SetLowerBoundaryCropSize(bounds);
+    cropFilter->SetUpperBoundaryCropSize(bounds);
+    cropFilter->Update();
+    working_mask = cropFilter->GetOutput();
+  }
   StopCurrentStep<MaskImageType>(working_mask);
 
   //--------------------------------------------------------------------
@@ -395,7 +437,6 @@ GenerateOutputInformation()
   PrintMemory(GetVerboseMemoryFlag(), "After count label");
  
   // Decompose the first label
-  static const unsigned int Dim = ImageType::ImageDimension;
   if (initialNumberOfLabels<2) {
     // Structuring element radius
     typename ImageType::SizeType radius;
@@ -588,7 +629,7 @@ ComputeTracheaVolume()
 
 //--------------------------------------------------------------------
 template <class ImageType>
-void 
+void
 clitk::ExtractLungFilter<ImageType>::
 SearchForTrachea()
 {
@@ -603,8 +644,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 +657,6 @@ SearchForTrachea()
           if (GetVerboseStepFlag()) {
             std::cout << "\t Found trachea with volume " << volume << " cc." << std::endl;
           }
-          stop = true; 
         }
         else {
           if (GetVerboseStepFlag()) {
@@ -629,6 +669,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);
index 5c78d4ea436355e1d8e459ba8a69e9eac3f5d36d..aeae1f988806c100c6198f407f59baefc5134222 100644 (file)
@@ -165,14 +165,21 @@ namespace clitk
       output->SetOrigin(origin);
     }
     
-    // force index to zero
-    typename ImageType::RegionType region;
-    region = output->GetLargestPossibleRegion();
-    typename ImageType::IndexType index;
+    // adjust image origin and force index to zero 
+    typename ImageType::RegionType region = output->GetLargestPossibleRegion();
+    typename ImageType::IndexType index = region.GetIndex();
+    typename ImageType::PointType origin = output->GetOrigin();
+    typename ImageType::SpacingType spacing = output->GetSpacing();
+    if (mArgsInfo.verbose_flag) std::cout << "origin before crop " << origin << std::endl;
+    for (unsigned int i = 0; i < output->GetImageDimension(); i++)
+      origin[i] += index[i]*spacing[i];
+    if (mArgsInfo.verbose_flag) std::cout << "origin after crop " << origin << std::endl;
+    output->SetOrigin(origin);
+
     index.Fill(itk::NumericTraits<double>::Zero);
     region.SetIndex(index);
     output->SetRegions(region);
-
+    
     // Write/Save results
     this->template SetNextOutput<ImageType>(output); 
   }
index 6f4b932c5a6f24f1ddf8f56f43e90d43f660d5ce..ca7e91607876aa9d33c608f907177a58513aa453 100644 (file)
@@ -13,7 +13,7 @@ option "input2"          j    "Input second image filename"     string   no
 option "output"    o   "Output image filename"           string   yes
 
 option "scalar"           s    "Scalar value"            double   no
-option "operation" t   "Type of operation : \n With another image : 0=add, 1=multiply, 2=divide,\n 3=max, 4=min, 5=absdiff, 6=squareddiff,  7=difference, 8=relativ diff\n For 'scalar' : 0=add, 1=multiply, 2=inverse,\n 3=max, 4=min 5=absval 6=squareval\n 7=log 8=exp 9=sqrt 10=EPID"      int default="0" no 
+option "operation" t   "Type of operation : \n With another image : 0=add, 1=multiply, 2=divide,\n 3=max, 4=min, 5=absdiff, 6=squareddiff,  7=difference, 8=relativ diff\n For 'scalar' : 0=add, 1=multiply, 2=inverse,\n 3=max, 4=min 5=absval 6=squareval\n 7=log 8=exp 9=sqrt 10=EPID 11=divide 12=normalize (divide by max)"       int default="0" no 
 option "pixelValue" -  "Default value for NaN/Inf"     double   default="0.0"  no
 
 option "setFloatOutput" f "Set output to float pixel type" flag off
index f3b1d449718abdc68b8c1333d0d9ef85ee56d535..38f7c505ba3cd3cf3bad54011e1269794c86cc08 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "clitkImageCommon.h"
 
+#include "itkMinimumMaximumImageCalculator.h"
+
 namespace clitk
 {
 
@@ -110,6 +112,15 @@ void ImageArithmGenericFilter<args_info_type>::UpdateWithInputImageType()
   typename ImageType::Pointer input2 = NULL;
   IteratorType it2;
 
+  // Special case for normalisation
+  if (mTypeOfOperation == 12) {
+    typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxFilterType;
+    typename MinMaxFilterType::Pointer ff = MinMaxFilterType::New();
+    ff->SetImage(input1);
+    ff->ComputeMaximum();
+    mScalar = ff->GetMaximum();
+    mTypeOfOperation = 11; // divide
+  }
 
   if (mIsOperationUseASecondImage) {
       // Read input2
@@ -370,6 +381,13 @@ void clitk::ImageArithmGenericFilter<args_info_type>::ComputeImage(Iter1 it, Ite
       ++ito;
     }
     break;
+  case 11: // divide
+    while (!it.IsAtEnd()) {
+      ito.Set(PixelTypeDownCast<double, PixelType>((double)it.Get() / mScalar) );
+      ++it;
+      ++ito;
+    }
+    break;
   default: // error ?
     std::cerr << "ERROR : the operation number (" << mTypeOfOperation << ") is not known." << std::endl;
     exit(-1);
index 34396de5fab977203fe4bc1f17c6c66990b47af6..f20765db15245d06d899cfe091f7541e60f6a627 100644 (file)
@@ -214,7 +214,9 @@ ELSE(WIN32)
   ADD_EXECUTABLE(vv vv.cxx)
 ENDIF(WIN32)
 
-TARGET_LINK_LIBRARIES(vv vvLib)
+#TARGET_LINK_LIBRARIES(vv vvLib)
+# QtNetwork added specifically for Fedora build
+TARGET_LINK_LIBRARIES(vv vvLib QtNetwork)
 
 
 #=========================================================
diff --git a/vv/icons/identity.png b/vv/icons/identity.png
new file mode 100644 (file)
index 0000000..dbce16d
Binary files /dev/null and b/vv/icons/identity.png differ
index 9dd0d96908e9470018c54055fdaaf9ba36c44079..15a864843ba26c5767d6a665b72bd65063f245ca 100644 (file)
@@ -39,5 +39,6 @@
     <file>icons/adjustsize.png</file>
     <file>icons/standardbutton-apply-16.png</file>
     <file>icons/standardbutton-cancel-16.png</file>
+    <file>icons/identity.png</file>
   </qresource>
 </RCC>
index da2bda3828c8bdb081e4786184eb49e1568c191f..e8d3ba8187718616c917a166ae14e7e5476f4654 100644 (file)
@@ -122,55 +122,6 @@ void vvInfoPanel::setCurrentInfo(int visibility, double x, double y, double z, d
 //------------------------------------------------------------------------------
 
 
-//------------------------------------------------------------------------------
-void vvInfoPanel::setViews(int window, int view, int slice)
-{/*
-  QString viewString;
-  switch (view) {
-  case 0: {
-    viewString = "Sagital,  ";
-    break;
-  }
-  case 1: {
-    viewString = "Coronal, ";
-    break;
-  }
-  case 2: {
-    viewString = "Axial,   ";
-    break;
-  }
-  }
-
-  QString text = viewString;
-  if (view != -1) {
-    text += "current slice : ";
-    text += QString::number(slice);
-  } else {
-    text = "Disable";
-  }
-
-  switch (window) {
-  case 0: {
-    ULLabel->setText(text);
-    break;
-  }
-  case 1: {
-    URLabel->setText(text);
-    break;
-  }
-  case 2: {
-    DLLabel->setText(text);
-    break;
-  }
-  case 3: {
-    DRLabel->setText(text);
-    break;
-  }
-  }*/
-}
-//------------------------------------------------------------------------------
-
-
 //------------------------------------------------------------------------------
 void vvInfoPanel::setMemoryInMb(QString text)
 {
index 5418703e04cc4f74b21e225341db76a65a1a0191..4a665e1aaa34ba09029fa843a5130cf5feabc43c 100644 (file)
@@ -39,7 +39,6 @@ public:
     void setDimension(QString text);
     void setSizePixel(QString text);
     void setCurrentInfo(int visibility, double x, double y, double z, double X, double Y, double Z, double value);
-    void setViews(int window, int view, int slice);
     void setMemoryInMb(QString text);
 
 public slots:
index 07e027951af623749b2408d3afe56e02139b7006..882bc2b16d631c7cf68233f30ac3fe0c3640cf81 100644 (file)
@@ -160,6 +160,11 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   connect(actionAdd_fusion_image,SIGNAL(triggered()),this,SLOT(SelectFusionImage()));
   contextActions.push_back(actionAdd_fusion_image);
 
+  contextMenu.addSeparator();
+  QAction* actionResetMatrix = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/identity.png")),
+                                                      tr("Reset transformation to identity"));
+  connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
+
   // TRIAL DS
   /*
   QMenu * m = new QMenu(menubar);
@@ -910,8 +915,6 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
                 this, SLOT(OverlayChanged(int,double,double)));
         connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
                 this, SLOT(FusionChanged(int,double)));
-        connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
-                this,SLOT(WindowsChanged(int, int, int)));
         connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
                 this,SLOT(WindowLevelChanged(double, double, int, int)));
         connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
@@ -1625,13 +1628,6 @@ void vvMainWindow::FusionChanged(int visibility, double value)
 }
 //------------------------------------------------------------------------------
 
-//------------------------------------------------------------------------------
-void vvMainWindow::WindowsChanged(int window, int view, int slice)
-{
-  infoPanel->setViews(window, view, slice);
-}
-//------------------------------------------------------------------------------
-
 //------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelChanged(double window, double level,int preset,int colormap)
 {
@@ -1912,6 +1908,16 @@ void vvMainWindow::SelectFusionImage()
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvMainWindow::ResetTransformationToIdentity()
+{
+  std::string actorType = DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString().toStdString();
+  int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
+  mSlicerManagers[index]->ResetTransformationToIdentity(actorType);
+  ImageInfoChanged();
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvMainWindow::AddFusionImage(int index, QString file)
 {
@@ -2831,8 +2837,6 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
           this, SLOT(OverlayChanged(int,double,double)));
   connect(mSlicerManagers.back(), SIGNAL(UpdateFusion(int, double)),
           this, SLOT(FusionChanged(int,double)));
-  connect(mSlicerManagers.back(), SIGNAL(UpdateWindows(int, int, int)),
-          this,SLOT(WindowsChanged(int, int, int)));
   connect(mSlicerManagers.back(), SIGNAL(WindowLevelChanged(double, double,int, int)),
           this,SLOT(WindowLevelChanged(double, double, int, int)));
   connect(mSlicerManagers.back(), SIGNAL(UpdateSlice(int,int)),
index d47dacce49a837b32d8dc2cd7877bc3cdfad7fff..7da8a9171ecc8e0018cdf5606daef1f947eb75ed 100644 (file)
@@ -101,7 +101,6 @@ public slots:
   void SegmentationOnCurrentImage();
   void SurfaceViewerLaunch();
 
-  void WindowsChanged(int window, int view, int slice);
   void WindowLevelChanged(double window, double level,int preset, int colormap);
   void UpdateSlice(int slicer, int slice);
   void UpdateTSlice(int slicer, int slice);
@@ -140,6 +139,7 @@ public slots:
   void OpenField();
   void SelectOverlayImage();
   void SelectFusionImage();
+  void ResetTransformationToIdentity();
 
   void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b);
   void SetOverlayProperty(int color);
@@ -211,6 +211,4 @@ private:
   
 };
 
-#include "vvMainWindow.txx"
-
 #endif
diff --git a/vv/vvMainWindow.txx b/vv/vvMainWindow.txx
deleted file mode 100644 (file)
index 7cdb613..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*=========================================================================
-  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
-
-  Authors belong to:
-  - University of LYON              http://www.universite-lyon.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
-  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-  PURPOSE.  See the copyright notices for more information.
-
-  It is distributed under dual licence
-
-  - BSD        See included LICENSE.txt file
-  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-===========================================================================**/
-// }
index 43583571456b3d12d6253bc27e7fb17449eb893a..6100c56dfcc84aa5ad97ca19c980bad135cfd6c6 100644 (file)
@@ -836,8 +836,8 @@ void vvSlicer::UpdateDisplayExtent()
   
   // Overlay image actor
   if (mOverlay && mOverlayActor->GetVisibility()) {
+    AdjustResliceToSliceOrientation(mOverlayReslice);
     int overExtent[6];
-    mOverlayReslice->GetOutput()->UpdateInformation();
     this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
     ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
     mOverlayActor->SetDisplayExtent( overExtent );
@@ -845,8 +845,8 @@ void vvSlicer::UpdateDisplayExtent()
 
   // Fusion image actor
   if (mFusion && mFusionActor->GetVisibility()) {
+    AdjustResliceToSliceOrientation(mFusionReslice);
     int fusExtent[6];
-    mFusionReslice->GetOutput()->UpdateInformation();
     this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
     ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
     mFusionActor->SetDisplayExtent(fusExtent);
index 987162cc6b420a0d3c8d25e557174c5b5e27945e..fd8f09fccc30b4667a6e271076ca5000f2839512 100644 (file)
@@ -736,6 +736,27 @@ double vvSlicerManager::GetColorLevel()
 }
 //----------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)
+{
+  if(actorType == "image")
+    this->GetImage()->GetTransform()->Identity();
+  else if(actorType == "overlay")
+    this->GetSlicer(0)->GetOverlay()->GetTransform()->Identity();
+  else if(actorType == "fusion")
+    this->GetSlicer(0)->GetFusion()->GetTransform()->Identity();
+  else if(actorType == "vf")
+    this->GetVF()->GetTransform()->Identity();
+  else
+    return;
+
+  for(int i=0; i< this->GetNumberOfSlicers(); i++){
+    this->GetSlicer(i)->ForceUpdateDisplayExtent();
+    this->GetSlicer(i)->ResetCamera();
+    this->GetSlicer(i)->Render();
+  }
+}
+//------------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 void vvSlicerManager::Render()
index a148d196e6ebdeeb175c4d7407b2276e3c77a2ff..5e0ef60c24194669ebf78e5d30a4eb0aa2aca145 100644 (file)
@@ -166,6 +166,7 @@ class vvSlicerManager : public QObject {
   void UpdateViews(int current, int slicer);
   void UpdateLinked(int slicer);
   void UpdateLinkedNavigation(vvSlicer *slicer, bool bPropagate=false);
+  void ResetTransformationToIdentity(const std::string actorType);
   void Render();
 
   void AddLink(std::string newId) {
@@ -211,7 +212,6 @@ signals :
   void UpdateVector(int display, double x, double y, double z, double value);
   void UpdateOverlay(int display, double valueOver, double valueRef);
   void UpdateFusion(int display, double valueFus);
-  void UpdateWindows(int slicer, int view, int slice);
   void UpdateOrientation(int slicer, int orientation);
   void UpdateSlice(int slicer, int slice);
   void UpdateTSlice(int slicer, int slice);