]> Creatis software - clitk.git/commitdiff
add nbewnew parameters to SliceBySliceSetBackgroundFromLineSeparation
authorDavid Sarrut <david.sarrut@gmail.com>
Fri, 3 Feb 2012 06:57:12 +0000 (07:57 +0100)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Tue, 2 Apr 2013 08:16:24 +0000 (10:16 +0200)
itk/clitkSegmentationUtils.h
itk/clitkSegmentationUtils.txx

index e8e2f89880c23f592f047e5ca86d893ba3ebd94e..5ac8c4c51e86c2d7b5345fcefda25ea8ba8b3ec0 100644 (file)
@@ -343,7 +343,7 @@ namespace clitk {
                                               bool keepIfEqual=false);
   template<class ImageType>
   void 
-  SliceBySliceSetBackgroundFromLineSeparation(ImageType * input, 
+  SliceBySliceSetBackgroundFromLineSeparation_pt(ImageType * input, 
                                               std::vector<typename ImageType::PointType> & lA, 
                                               std::vector<typename ImageType::PointType> & lB, 
                                               typename ImageType::PixelType BG, 
index 0d758e447caa88e0a33745a00d6b2faffc772ea2..75e5ef35f982b2d7e33fff174af5ae7b77c8ad40 100644 (file)
@@ -775,16 +775,16 @@ namespace clitk {
     typename ImageType::PointType offset;
     offset[0] = offset[1] = offset[2] = 0.0;
     offset[mainDirection] = offsetToKeep;
-    SliceBySliceSetBackgroundFromLineSeparation<ImageType>(input, lA, lB, BG, offset, keepIfEqual);
+    SliceBySliceSetBackgroundFromLineSeparation_pt<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)
+  SliceBySliceSetBackgroundFromLineSeparation_pt(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());
@@ -800,6 +800,8 @@ namespace clitk {
       // Check that the current slice correspond to the current point
       input->TransformIndexToPhysicalPoint(siter.GetIndex(), C);
       if ((fabs(C[2] - lA[i][2]))>0.01) { // is !equal with a tolerance of 0.01 mm
+        // FIXME : if not the same slices, should advance i or slice (not done yet)
+        //        clitkExceptionMacro("Error list of point and slice do not start at the same location");
       }
       else {
         // Define A,B,C points
@@ -818,17 +820,19 @@ namespace clitk {
           bool isPositive = s<0;
           while (!siter.IsAtEndOfSlice()) {
             while (!siter.IsAtEndOfLine()) {
-              // 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) {
-                if (!keepIfEqual) siter.Set(BG); // on the line, we decide to remove
-              }
-              if (isPositive) {
-                if (s > 0) siter.Set(BG);
-              }
-              else {
-                if (s < 0) siter.Set(BG); 
+              if (siter.Get() != BG) { // do only if not BG
+                // 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) {
+                  if (!keepIfEqual) siter.Set(BG); // on the line, we decide to remove
+                }
+                if (isPositive) {
+                  if (s > 0) siter.Set(BG);
+                }
+                else {
+                  if (s < 0) siter.Set(BG); 
+                }
               }
               ++siter;
             }