]> Creatis software - clitk.git/commitdiff
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 4 Mar 2013 15:44:55 +0000 (16:44 +0100)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Mon, 4 Mar 2013 15:44:55 +0000 (16:44 +0100)
24 files changed:
common/clitkCommon.h
common/clitkCommon.txx
common/clitkFilterBase.cxx
common/clitkFilterBase.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx
itk/clitkExtractSliceFilter.txx
itk/clitkLabelImageOverlapMeasureFilter.txx
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx
itk/clitkSliceBySliceRelativePositionFilter.h
itk/clitkSliceBySliceRelativePositionFilter.txx
segmentation/CMakeLists.txt
segmentation/clitkConnectedComponentLabelingGenericFilter.txx
segmentation/clitkRelativePositionList.txx
segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx [new file with mode: 0644]
tools/clitkAffineTransformGenericFilter.txx
tools/clitkAutoCropGenericFilter.txx
tools/clitkImageArithm.cxx
tools/clitkImageArithm.ggo
tools/clitkImageArithmGenericFilter.txx
tools/clitkImageStatisticsGenericFilter.txx
vv/vvBinaryImageOverlayActor.cxx
vv/vvMainWindow.cxx

index 8f9ce0f0ee20fb8ad45b48f38876fc3d993695c5..8cd82fbe0b0bc1b20f38876368f0d6348615b1a9 100644 (file)
@@ -235,6 +235,11 @@ namespace clitk {
   template <typename M, typename V> 
   void MapToVecSecond(const M & m, V & v);
 
+  //--------------------------------------------------------------------
+  // Find/replace string
+  template<class T>
+  int inline findAndReplace(T& source, const T& find, const T& replace);
+
 #include "clitkCommon.txx"
 
 } // end namespace
index 5ee83bdca8f4f3efc23ae2aa8dc12ad28a2fe36e..845e62fe520deb89def17b26d99c0e3fa7be1c98 100644 (file)
@@ -235,5 +235,22 @@ void MapToVecSecond(const  M & m, V & v) {
 }
 //--------------------------------------------------------------------
 
+
+//--------------------------------------------------------------------
+//http://stackoverflow.com/questions/1494399/how-do-i-search-find-and-replace-in-a-standard-string
+template<class T>
+int inline findAndReplace(T& source, const T& find, const T& replace)
+{
+  int num=0;
+  int fLen = find.size();
+  int rLen = replace.size();
+  for (int pos=0; (pos=source.find(find, pos))!=T::npos; pos+=rLen) {
+    num++;
+    source.replace(pos, fLen, replace);
+  }
+  return num;
+}
+//--------------------------------------------------------------------
+
 #endif /* end #define CLITKCOMMON_TXX */
 
index 32dd9b46cfbeb49fe75cf1e87097f729a9f3d213..f6bebad101072e7d8ed40fe62b710f962e802f1f 100644 (file)
@@ -49,7 +49,7 @@ void clitk::FilterBase::SetWarning(std::string e)
 
 
 //--------------------------------------------------------------------
-void clitk::FilterBase::StartNewStep(std::string s) 
+void clitk::FilterBase::StartNewStep(std::string s, bool endl
 {
   if (Cancelled()) {
     throw clitk::ExceptionObject("Filter is canceled.");
@@ -69,7 +69,8 @@ void clitk::FilterBase::StartNewStep(std::string s)
 
   m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
   if (GetVerboseStepFlag()) {
-    std::cout << m_CurrentStepName << std::endl;
+    std::cout << m_CurrentStepName;
+    if (endl) std::cout << std::endl;
     //"Step " << GetCurrentStepId() << " -- " << s << std::endl;
   }
 }
index b05f64d24b81b97be443fd0f4e2ee1686b4978c4..7403f37fe0a041fa6a1b0ea85c696b65e1a302f7 100644 (file)
@@ -118,7 +118,7 @@ namespace clitk {
   protected:
     FilterBase();
     virtual ~FilterBase() {}    
-    void StartNewStep(std::string s);
+    void StartNewStep(std::string s, bool endl=true);
     template<class TInternalImageType>
     void StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt="");
     void StopCurrentStep();
index 99465547695d6403dea2c271e55ffba93da8c14b..781775f0cc9541c488ca0ddfa4b8566b8ddc9779 100644 (file)
@@ -143,6 +143,9 @@ namespace clitk {
     itkGetConstMacro(Radius, double);
     itkSetMacro(Radius, double);
 
+    itkSetMacro(K1, double);
+    itkGetMacro(K1, double);
+
     typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; }
 
     // I dont want to verify inputs information
@@ -171,6 +174,7 @@ namespace clitk {
     bool m_FuzzyMapOnlyFlag;
     bool m_FastFlag;
     double m_Radius;
+    double m_K1;
 
     virtual void GenerateOutputInformation();
     virtual void GenerateInputRequestedRegion();
index ddcad0e16c445959381f5b197d7b94cce3f35ece..a3759f49fa2f69606401d0d5289faaf96c70f3d3 100644 (file)
@@ -65,6 +65,7 @@ AddRelativePositionConstraintToLabelImageFilter():
   FuzzyMapOnlyFlagOff();
   FastFlagOff();
   SetRadius(2.0);
+  SetK1(vcl_acos(-1.0)/2);
 }
 //--------------------------------------------------------------------
 
@@ -387,12 +388,9 @@ GenerateData()
     relPosFilter->SetInput(working_image);
     relPosFilter->SetAlpha1(m_Angle1[i]); // xy plane
     relPosFilter->SetAlpha2(m_Angle2[i]);
-    relPosFilter->SetK1(M_PI/2.0); // Opening parameter, default = pi/2
-
-    // relPosFilter->SetFast(true);
-    // relPosFilter->SetRadius(1); // seems sufficient in this case
-
+    relPosFilter->SetK1(GetK1());// M_PI/2.0); // Opening parameter, default = pi/2
     // relPosFilter->SetVerboseProgress(true);
+
     relPosFilter->Update();
     relPos = relPosFilter->GetOutput();
 
@@ -444,6 +442,7 @@ GenerateData()
       resampleFilter->SetGaussianFilteringEnabled(false);
       resampleFilter->Update();
       relPos = m_FuzzyMap = resampleFilter->GetOutput();
+      StopCurrentStep<FloatImageType>(relPos);
 
       // Need to put exactly the same size
       if (relPos->GetLargestPossibleRegion() != input->GetLargestPossibleRegion()) {
index 43874d0265f60cd70b11c5916a5b3c5bea85a74c..a449388fbdca9516594dc425ecb5510b5087e9cf 100644 (file)
@@ -106,6 +106,7 @@ GenerateData() {
   m_region.SetSize(m_size);
   int start = m_index[GetDirection()];
   this->SetNumberOfOutputs(m_NumberOfSlices);
+  // deprecated : use SetNumberOfIndexedInputs ? FIXME
 
   //--------------------------------------------------------------------
   // loop ExtractImageFilter with region updated, push_back
@@ -122,7 +123,7 @@ GenerateData() {
     extract->SetDirectionCollapseToSubmatrix();
 #endif
     extract->Update();
-    SetNthOutput(i, extract->GetOutput());
+    this->SetNthOutput(i, extract->GetOutput());
   }
   return;
 }
index a29aa6a3f810eb1987a8adbd2f62b82bc7d1e4a2..037570916b0346be55ed56ff47cf1988485db821 100644 (file)
@@ -94,9 +94,17 @@ GenerateData()
   ImagePointer image_intersection = clitk::Clone<ImageType>(input1);
   clitk::Or<ImageType>(image_union, input2, GetBackgroundValue());
   clitk::And<ImageType>(image_intersection, input2, GetBackgroundValue());
+
+  ImagePointer image_1NotIn2 = clitk::Clone<ImageType>(input1);
+  clitk::AndNot<ImageType>(image_1NotIn2, input2, GetBackgroundValue());
   
+  ImagePointer image_2NotIn1 = clitk::Clone<ImageType>(input2);
+  clitk::AndNot<ImageType>(image_2NotIn1, input1, GetBackgroundValue());
+
   //writeImage<ImageType>(image_union, "union.mha");
   //writeImage<ImageType>(image_intersection, "intersection.mha");
+  //writeImage<ImageType>(image_1NotIn2, "image_1NotIn2.mha");
+  //writeImage<ImageType>(image_2NotIn1, "image_2NotIn1.mha");
   
   // Compute size
   typedef itk::LabelStatisticsImageFilter<ImageType, ImageType> StatFilterType;
@@ -121,12 +129,24 @@ GenerateData()
   statFilter->Update();
   int in2 = statFilter->GetCount(GetLabel1());
 
+  statFilter->SetInput(image_1NotIn2);
+  statFilter->SetLabelInput(image_1NotIn2);
+  statFilter->Update();
+  int l1notIn2 = statFilter->GetCount(GetLabel1());
+
+  statFilter->SetInput(image_2NotIn1);
+  statFilter->SetLabelInput(image_2NotIn1);
+  statFilter->Update();
+  int l2notIn1 = statFilter->GetCount(GetLabel1());
+
   double dice = 2.0*(double)inter/(double)(in1+in2);
   int width = 6;
   std::cout << std::setw(width) << in1 << " "
             << std::setw(width) << in2 << " "
             << std::setw(width) << inter  << " "
             << std::setw(width) << u  << " "
+            << std::setw(width) << l1notIn2  << " "
+            << std::setw(width) << l2notIn1  << " "
             << std::setw(width) << dice << " "; //std::endl;
 }
 //--------------------------------------------------------------------
index 6389ad135c4c3202701b3eaed5c50729d082d365..e8e2f89880c23f592f047e5ca86d893ba3ebd94e 100644 (file)
@@ -85,11 +85,13 @@ namespace clitk {
   template<class ImageType>
   typename ImageType::Pointer
   AutoCrop(const ImageType * input, 
-           typename ImageType::PixelType BG) {
+           typename ImageType::PixelType BG, 
+           const bool useBorderFlag=false) {
     typedef clitk::AutoCropFilter<ImageType> AutoCropFilterType;
     typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
     autoCropFilter->SetInput(input);
     autoCropFilter->SetBackgroundValue(BG);
+    autoCropFilter->SetUseBorder(useBorderFlag);
     autoCropFilter->Update();   
     return autoCropFilter->GetOutput();
   }
@@ -337,7 +339,16 @@ namespace clitk {
                                               std::vector<typename ImageType::PointType> & lB, 
                                               typename ImageType::PixelType BG, 
                                               int mainDirection, 
-                                              double offsetToKeep);
+                                              double offsetToKeep, 
+                                              bool keepIfEqual=false);
+  template<class ImageType>
+  void 
+  SliceBySliceSetBackgroundFromLineSeparation(ImageType * input, 
+                                              std::vector<typename ImageType::PointType> & lA, 
+                                              std::vector<typename ImageType::PointType> & lB, 
+                                              typename ImageType::PixelType BG, 
+                                              typename ImageType::PointType offsetToKeep, 
+                                              bool keepIfEqual=false);
   //--------------------------------------------------------------------
 
 
index a57d8136becb4b919b1b1bc9360f6343c6547028..0d758e447caa88e0a33745a00d6b2faffc772ea2 100644 (file)
@@ -354,7 +354,7 @@ namespace clitk {
       ++iter;
     }
     if (!found) return false;
-    input->TransformIndexToPhysicalPoint(max, point);
+    input->TransformIndexToPhysicalPoint(max, point); // half of the pixel
     return true;
   }
   //--------------------------------------------------------------------
@@ -382,14 +382,12 @@ namespace clitk {
                  int dim, double max, bool autoCrop,
                  typename ImageType::PixelType BG) 
   {
-    typename ImageType::PointType p;
+    typename ImageType::PointType p; 
+    
     image->TransformIndexToPhysicalPoint(image->GetLargestPossibleRegion().GetIndex()+
                                          image->GetLargestPossibleRegion().GetSize(), p);
-    // Add GetSpacing because remove Lower or equal than
-    // DD(max);
-    // DD(p);
-    // DD(max+image->GetSpacing()[dim]);
-    return CropImageAlongOneAxis<ImageType>(image, dim, max+image->GetSpacing()[dim], p[dim], autoCrop, BG);
+
+    return CropImageAlongOneAxis<ImageType>(image, dim, max, p[dim], autoCrop, BG);
   }
   //--------------------------------------------------------------------
 
@@ -404,16 +402,24 @@ namespace clitk {
     // Compute region size
     typename ImageType::RegionType region;
     typename ImageType::SizeType size = image->GetLargestPossibleRegion().GetSize();
-    typename ImageType::PointType p = image->GetOrigin();
+    
+    // Starting index
+    typename ImageType::PointType p = image->GetOrigin(); // not at pixel center !
     if (min > p[dim]) p[dim] = min; // Check if not outside the image
     typename ImageType::IndexType start;
     image->TransformPhysicalPointToIndex(p, start);
-    double m = image->GetOrigin()[dim] + size[dim]*image->GetSpacing()[dim];
+
+    // Size of the region
+    // -1 because last point is size -1
+    double m = image->GetOrigin()[dim] + (size[dim]-1)*image->GetSpacing()[dim];
     if (max > m) p[dim] = m; // Check if not outside the image
     else p[dim] = max;
+
     typename ImageType::IndexType end;
     image->TransformPhysicalPointToIndex(p, end);
-    size[dim] = abs(end[dim]-start[dim]);
+    size[dim] = abs(end[dim]-start[dim])+1;// +1 because we want to include the point. 
+    
+    // Set region
     region.SetIndex(start);
     region.SetSize(size);
   
@@ -762,9 +768,24 @@ namespace clitk {
                                               std::vector<typename ImageType::PointType> & lB, 
                                               typename ImageType::PixelType BG, 
                                               int mainDirection, 
-                                              double offsetToKeep)
+                                              double offsetToKeep,
+                                              bool keepIfEqual)
   {
     assert((mainDirection==0) || (mainDirection==1));
+    typename ImageType::PointType offset;
+    offset[0] = offset[1] = offset[2] = 0.0;
+    offset[mainDirection] = offsetToKeep;
+    SliceBySliceSetBackgroundFromLineSeparation<ImageType>(input, lA, lB, BG, offset, keepIfEqual);
+  }
+  template<class ImageType>
+  void 
+  SliceBySliceSetBackgroundFromLineSeparation(ImageType * input, 
+                                              std::vector<typename ImageType::PointType> & lA, 
+                                              std::vector<typename ImageType::PointType> & lB, 
+                                              typename ImageType::PixelType BG, 
+                                              typename ImageType::PointType offsetToKeep,
+                                              bool keepIfEqual)
+  {
     typedef itk::ImageSliceIteratorWithIndex<ImageType> SliceIteratorType;
     SliceIteratorType siter = SliceIteratorType(input, input->GetLargestPossibleRegion());
     siter.SetFirstDirection(0);
@@ -789,7 +810,10 @@ namespace clitk {
         bool p = (A[0] == B[0]) && (A[1] == B[1]);
       
         if (!p) {
-          C[mainDirection] += offsetToKeep; // I know I must keep this point
+          //C[mainDirection] += offsetToKeep; // I know I must keep this point
+          C[0] += offsetToKeep[0];
+          C[1] += offsetToKeep[1];
+          //C[2] += offsetToKeep[2]; 
           double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
           bool isPositive = s<0;
           while (!siter.IsAtEndOfSlice()) {
@@ -797,7 +821,9 @@ namespace clitk {
               // Very slow, I know ... but image should be very small
               input->TransformIndexToPhysicalPoint(siter.GetIndex(), C);
               double s = (B[0] - A[0]) * (C[1] - A[1]) - (B[1] - A[1]) * (C[0] - A[0]);
-              if (s == 0) siter.Set(BG); // on the line, we decide to remove
+              if (s == 0) {
+                if (!keepIfEqual) siter.Set(BG); // on the line, we decide to remove
+              }
               if (isPositive) {
                 if (s > 0) siter.Set(BG);
               }
@@ -1340,14 +1366,14 @@ namespace clitk {
 
     }
 
-    // Debug dmap
     /*
-      typedef itk::Image<float,3> FT;
-      FT::Pointer f = FT::New();
-      typename FT::Pointer d1 = clitk::JoinSlices<FT>(dmaps1, S1, 2);
-      typename FT::Pointer d2 = clitk::JoinSlices<FT>(dmaps2, S2, 2);
-      writeImage<FT>(d1, "d1.mha");
-      writeImage<FT>(d2, "d2.mha");
+    // Debug dmap
+    typedef itk::Image<float,3> FT;
+    FT::Pointer f = FT::New();
+    typename FT::Pointer d1 = clitk::JoinSlices<FT>(dmaps1, S1, 2);
+    typename FT::Pointer d2 = clitk::JoinSlices<FT>(dmaps2, S2, 2);
+    writeImage<FT>(d1, "d1.mha");
+    writeImage<FT>(d2, "d2.mha");
     */
   }
   //--------------------------------------------------------------------
index ba59467f5ece21cc3b7538ba47ce40c19153297a..5989e20054c5229a0146543a5be06dba1d60444c 100644 (file)
@@ -138,4 +138,8 @@ namespace clitk {
 #include "clitkSliceBySliceRelativePositionFilter.txx"
 #endif
 
+typedef unsigned char                    PixelType_uchar;
+typedef itk::Image<PixelType_uchar, 3>   ImageType_uchar;    
+extern template class clitk::SliceBySliceRelativePositionFilter<ImageType_uchar>;
+
 #endif
index e68514da031c0f6f1a6725a2df78f97d0c189fe7..16571ea7a224df6b17d87425d7cf8bde619a66b0 100644 (file)
@@ -43,6 +43,7 @@ SliceBySliceRelativePositionFilter():
   SetObjectCCLSelectionDirection(1);
   ObjectCCLSelectionIgnoreSingleCCLFlagOff();
   VerboseSlicesFlagOff();
+  this->SetK1(vcl_acos(-1.0)/2);
 }
 //--------------------------------------------------------------------
 
@@ -98,7 +99,8 @@ PrintOptions(std::ostream & os)
      << "ObjectCCLSelectionIgnoreSingleCCLFlag = " << this->GetObjectCCLSelectionIgnoreSingleCCLFlag() << std::endl    
      << "IgnoreEmptySliceObjectFlag = " << this->GetIgnoreEmptySliceObjectFlag() << std::endl
      << "(RP) FastFlag              = " << this->GetFastFlag() << std::endl
-     << "(RP) Radius                = " << this->GetRadius() << std::endl;
+     << "(RP) Radius                = " << this->GetRadius() << std::endl
+     << "(RP) K1                    = " << this->GetK1() << std::endl;
 }
 //--------------------------------------------------------------------
 
@@ -238,6 +240,10 @@ GenerateOutputInformation()
     int nb=0;
     mObjectSlices[i] = LabelizeAndCountNumberOfObjects<SliceType>(mObjectSlices[i], 0, true, 1, nb);
 
+    if (GetVerboseSlicesFlag()) {
+      std::cout << "slice " << i << " nb = " << nb << std::endl;
+    }
+
     // If no object and empty slices and if we need the full fuzzy map, create a dummy one.
     if ((nb==0) && (this->GetFuzzyMapOnlyFlag())) {
       typename FloatSliceType::Pointer one = FloatSliceType::New();
@@ -295,6 +301,7 @@ GenerateOutputInformation()
         if (GetVerboseSlicesFlag()) {
           std::cout << "Slice " << i << std::endl;
           relPosFilter->VerboseStepFlagOn();
+          //relPosFilter->WriteStepFlagOn();
         }
         relPosFilter->WriteStepFlagOff();
         // relPosFilter->VerboseMemoryFlagOn();
@@ -319,6 +326,7 @@ GenerateOutputInformation()
         //        relPosFilter->SetComputeFuzzyMapFlag(this->GetComputeFuzzyMapFlag());      
         relPosFilter->SetFastFlag(this->GetFastFlag());
         relPosFilter->SetRadius(this->GetRadius());
+        relPosFilter->SetK1(this->GetK1());
 
         // Go !
         relPosFilter->Update();
index 64adbd9a1891ed995a7ffabd09fcd8643cf5dcdd..7e635ddf9332386f97d8678b2c33bd65f5a2aaeb 100644 (file)
@@ -8,6 +8,7 @@ ENDFOREACH(clitkTool)
 ADD_LIBRARY(clitkSegmentationGgoLib
             clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx
             clitkAnatomicalFeatureDatabase.cxx
+            clitkSliceBySliceRelativePositionFilter_uchar.cxx
             ${GGO_C_FILES})
 
 #=========================================================
index 1a5ab247e5eb158a095d7ce515e555c99610ee08..cb38852edfdaa53acf89af280b0dbad16167a017 100644 (file)
@@ -46,6 +46,7 @@ void clitk::ConnectedComponentLabelingGenericFilter<ArgsInfoType>::InitializeIma
 {  
   ADD_IMAGE_TYPE(Dim, uchar);
   ADD_IMAGE_TYPE(Dim, short);
+  ADD_IMAGE_TYPE(Dim, ushort);
   // ADD_IMAGE_TYPE(Dim, int);
   ADD_IMAGE_TYPE(Dim, float);
 }
index 4f4702b981c809b6705f1102bd1b4cebc32ac95d..8d89e9fd364320d058ec1ba6ad88950ea9e12e58 100644 (file)
@@ -173,19 +173,22 @@ GenerateOutputInformation() {
   for(uint i=0; i<mArgsInfoList.size(); i++) {
 
     // clitk::PrintMemory(true, "Start"); 
-    std::string text = "["+s+"] limits ";
+    // remove _S in station name
+    std::string sname = s;
+    clitk::findAndReplace<std::string>(sname, "_S", " ");
+    std::string text = "["+sname+"] ";
     if (mArgsInfoList[i].orientation_given) text += std::string(mArgsInfoList[i].orientation_arg[0])+" ";
     else text = text+"("+toString(mArgsInfoList[i].angle1_arg)+" "+
            toString(mArgsInfoList[i].angle2_arg)+" "+
            (mArgsInfoList[i].inverse_flag?"true":"false")+") ";
     text = text+mArgsInfoList[i].object_arg+" "+toString(mArgsInfoList[i].threshold_arg);
     if (mArgsInfoList[i].sliceBySlice_flag) {
-      text += " slice by slice";
+      text += " SbS";
     }
     else text += " 3D";
-    text += " spacing=" + toString(mArgsInfoList[i].spacing_arg);
+    text += " sp=" + toString(mArgsInfoList[i].spacing_arg)+" ";
 
-    StartNewStep(text);  
+    StartNewStep(text, false); // no endl
     typename RelPosFilterType::Pointer relPosFilter;
 
     // Is it slice by slice or 3D ?
@@ -198,6 +201,7 @@ GenerateOutputInformation() {
       f->SetUniqueConnectedComponentBySliceFlag(mArgsInfoList[i].uniqueCCL_flag);
       f->SetObjectCCLSelectionFlag(mArgsInfoList[i].uniqueObjectCCL_flag);
       f->IgnoreEmptySliceObjectFlagOn();
+      f->SetVerboseSlicesFlag(mArgsInfoList[i].verboseSlices_flag);
       //f->SetObjectCCLSelectionDimension(0);
       //f->SetObjectCCLSelectionDirection(-1);
       //f->SetAutoCropFlag(false);
@@ -227,7 +231,7 @@ GenerateOutputInformation() {
       filter->SetInput(1, m_reference);
       filter->Update();
     }
-    
+    std::cout << std::endl;    
   }
 }
 //--------------------------------------------------------------------
@@ -260,9 +264,12 @@ SetFilterOptions(typename RelPosFilterType::Pointer filter, ArgsInfoType & optio
   ImagePointer object = GetAFDB()->template GetImage<ImageType>(options.object_arg);
   filter->SetInputObject(object);
   filter->WriteStepFlagOff();
+  filter->SetRadius(options.radius_arg);
+  if (options.writeStep_flag) filter->WriteStepFlagOn();
   filter->SetVerboseImageSizeFlag(GetVerboseImageSizeFlag());
   filter->SetFuzzyThreshold(options.threshold_arg);
   filter->SetInverseOrientationFlag(options.inverse_flag); // MUST BE BEFORE AddOrientationTypeString
+  filter->SetFastFlag(options.fastFlag_flag);
 
   if (options.orientation_given == 1)  {
     for(uint i=0; i<options.orientation_given; i++) 
diff --git a/segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx b/segmentation/clitkSliceBySliceRelativePositionFilter_uchar.cxx
new file mode 100644 (file)
index 0000000..f0138af
--- /dev/null
@@ -0,0 +1,29 @@
+/*=========================================================================
+  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 CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_UCHARH
+#define CLITKSLICEBYSLICERELATIVEPOSITIONFILTER_UCHARH
+
+// clitk
+#include "clitkSliceBySliceRelativePositionFilter.h"
+
+typedef unsigned char                    PixelType_uchar;
+typedef itk::Image<PixelType_uchar, 3>   ImageType_uchar;    
+template class clitk::SliceBySliceRelativePositionFilter<ImageType_uchar>;
+
+#endif
index 93cd16c91c2928455b4af569a450a985ecaa0a49..0fa4869f2af12d9f680373060faa16ccba109f85 100644 (file)
@@ -211,6 +211,12 @@ AffineTransformGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
     typename itk::Matrix<double, Dimension, Dimension> invRotMatrix( clitk::GetRotationalPartMatrix(invMatrix) );
     typename itk::Vector<double,Dimension> invTrans =  clitk::GetTranslationPartMatrix(invMatrix);
 
+    // Display warning
+    if (m_ArgsInfo.spacing_given)
+      std::cout << "Warning --spacing ignored (because --transform_grid_flag)" << std::endl;
+    if (m_ArgsInfo.origin_given)
+      std::cout << "Warning --origin ignored (because --transform_grid_flag)" << std::endl;
+
     // Spacing is influenced by affine transform matrix and input direction
     typename InputImageType::SpacingType outputSpacing;
     outputSpacing = invRotMatrix *
index 933ce405dca1ae31d95060279c0d409390f19911..e20ec58a8862f532c8f23143edb7de8716bbeada 100644 (file)
@@ -37,9 +37,10 @@ template<class ArgsInfoType>
 template<unsigned int Dim>
 void clitk::AutoCropGenericFilter<ArgsInfoType>::InitializeImageType() 
 {  
-  // ADD_DEFAULT_IMAGE_TYPES(Dim);
+  //ADD_DEFAULT_IMAGE_TYPES(Dim);
   ADD_IMAGE_TYPE(Dim, uchar);
   ADD_IMAGE_TYPE(Dim, ushort);
+  ADD_IMAGE_TYPE(Dim, short);
   // ADD_IMAGE_TYPE(Dim, uint);
  //  ADD_IMAGE_TYPE(Dim, ulong);
   // ADD_IMAGE_TYPE(Dim, int);
index 4cb22ca85c806ae1bb0d9f941913e8e91a152b01..e0c98212951e71258f4f3cd55f8bc565a3c4c809 100644 (file)
 ===========================================================================**/
 #ifndef CLITKIMAGEARITHM_CXX
 #define CLITKIMAGEARITHM_CXX
-/**
-   -------------------------------------------------
-   * @file   clitkImageArithm.cxx
-   * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
-   * @date   23 Feb 2008 08:37:53
-   -------------------------------------------------*/
 
 // clitk include
 #include "clitkImageArithm_ggo.h"
index fd018635cc45b863786141ad0200569e84591d54..5d85f523e4b4320f699aecf08a1d9954b4daa353 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 11=divide* 12=normalize (divide by max); \n* operations supported with vector fields as inputs."         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) 13=-ln(I/IO)**; \n* operations supported with vector fields as inputs. \n** for fluence image, if pixel value == 0, consider value=0.5"  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 4c2f0a58c6ef1f32cf858ddb5a02cfef31c0a722..f3040750d6f8cb61b81ffb9052f511ad579cd761 100644 (file)
@@ -391,6 +391,18 @@ void clitk::ImageArithmGenericFilter<args_info_type>::ComputeImage(Iter1 it, Ite
       ++ito;
     }
     break;
+  case 13: // -ln I/I0
+    while (!it.IsAtEnd()) {
+      if (it.Get() == 0) { // special case for fluence image with 0 value in a pixel -> consider 0.5
+        ito.Set(-log(0.5 / mScalar) );
+      }
+      else {
+        ito.Set(-log(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 7b9c78b1cb233a394cef58753e6f8a4d21374313..f5c82356dff35c50bd2a3c841d9dc07ae820bdea 100644 (file)
@@ -50,15 +50,7 @@ namespace clitk
       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
       UpdateWithDimAndPixelType<Dimension, unsigned char, Components>();
     }
-    
-//     else if (PixelType == "unsigned_int"){ 
-//       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and unsigned_int..." << std::endl;
-//       UpdateWithDimAndPixelType<Dimension, unsigned int, Components>();
-//     }
-    //     else if (PixelType == "char"){ 
-    //       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
-    //       UpdateWithDimAndPixelType<Dimension, signed char>();
-    //     }
+        
     else if(PixelType == "double"){  
       if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and double..." << std::endl;
       UpdateWithDimAndPixelType<Dimension, double, Components>(); 
@@ -148,12 +140,19 @@ namespace clitk
             typename ResamplerType::Pointer resampler = ResamplerType::New();
             resampler->SetInput(labelImage);
             resampler->SetOutputSpacing(input->GetSpacing());
+            resampler->SetGaussianFilteringEnabled(false);
             resampler->Update();
             labelImage = resampler->GetOutput();
+            //writeImage<LabelImageType>(labelImage, "test1.mha");
+            
+            typedef clitk::CropLikeImageFilter<LabelImageType> FilterType;
+            typename FilterType::Pointer crop = FilterType::New();
+            crop->SetInput(labelImage);
+            crop->SetCropLikeImage(input);
+            crop->Update();
+            labelImage = crop->GetOutput();                        
+            //writeImage<LabelImageType>(labelImage, "test2.mha");
 
-            typename itk::ImageBase<LabelImageType::ImageDimension>::RegionType reg 
-              = input->GetLargestPossibleRegion();
-            labelImage = ResizeImageLike<LabelImageType>(labelImage, &reg, 0);
           }
           else {
             std::cerr << "Mask image has a different size/spacing than input. Abort" << std::endl;
index a801ba0c27862f3957d87f59eeba766ff75bf9ac..b4a4a3df204dfcd5ce4980939010c8bfd1bd756f 100644 (file)
@@ -314,12 +314,23 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation,
 //----------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay)
 {
+  for(int i=0; i<3; i++) {
+    double a = (image->GetOrigin()[i] + inExtent[i*2]*image->GetSpacing()[i] - 
+                overlay->GetOrigin()[i]) / overlay->GetSpacing()[i];
+    double b = (image->GetOrigin()[i] + inExtent[i*2+1]*image->GetSpacing()[i] - 
+                overlay->GetOrigin()[i]) / overlay->GetSpacing()[i];
+    outExtent[i*2] = lrint(a);
+    outExtent[i*2+1] = lrint(b);
+  }
+
+  /* // FIXME (original)
   outExtent[0] = (int)lrint(((image->GetOrigin()[0] + inExtent[0]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]);
   outExtent[1] = (int)lrint(((image->GetOrigin()[0] + inExtent[1]*image->GetSpacing()[0]) - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0]);
   outExtent[2] = (int)lrint(((image->GetOrigin()[1] + inExtent[2]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]);
   outExtent[3] = (int)lrint(((image->GetOrigin()[1] + inExtent[3]*image->GetSpacing()[1]) - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1]);
   outExtent[4] = (int)lrint(((image->GetOrigin()[2] + inExtent[4]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]);
   outExtent[5] = (int)lrint(((image->GetOrigin()[2] + inExtent[5]*image->GetSpacing()[2]) - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2]);
+  */
 }
 //----------------------------------------------------------------------------
 
index a06870f5baf2074d74856776a9b49c36ff9e0adf..325287b314b04c8848e54ec7c33b7fe1c7671525 100644 (file)
@@ -739,7 +739,7 @@ void vvMainWindow::OpenDicom()
 {
   std::vector<std::string> files;
 
-  std::cout << "dicomSeriesSelector " << std::endl;
+  //std::cout << "dicomSeriesSelector " << std::endl;
   if (dicomSeriesSelector->exec() == QDialog::Accepted) {
     files = *(dicomSeriesSelector->GetFilenames());
     LoadImages(files, vvImageReader::DICOM);