]> Creatis software - clitk.git/commitdiff
*** empty log message ***
authorgrevillot <grevillot>
Fri, 25 Mar 2011 06:57:11 +0000 (06:57 +0000)
committergrevillot <grevillot>
Fri, 25 Mar 2011 06:57:11 +0000 (06:57 +0000)
tools/clitkImageExtractLine.cxx
tools/clitkImageExtractLine.ggo

index a4040dd2b05f1a6ce39ab52eb873e277286970f7..5360b02359a4f33521a20fa00aa530ee808d45ed 100644 (file)
@@ -104,75 +104,71 @@ int main(int argc, char * argv[])
     }
   }
   // args_info.integral_arg=1, so, it computes the integral
-  else if (lastIndex[0]-firstIndex[0]==0 && lastIndex[1]-firstIndex[1]==0 && lastIndex[2]-firstIndex[2]>0)
-    direction=1;
-  else if (lastIndex[0]-firstIndex[0]==0 && lastIndex[1]-firstIndex[1]>0 && lastIndex[2]-firstIndex[2]==0)
-    direction=2;
-  else if (lastIndex[0]-firstIndex[0]>0 && lastIndex[1]-firstIndex[1]==0 && lastIndex[2]-firstIndex[2]==0)
-    direction=3;
-  else{
-    //std::cout<<lastIndex[0]-firstIndex[0]<<"  "<<lastIndex[1]-firstIndex[1]<<"  "<<lastIndex[3]-firstIndex[3]<<std::endl;
-    std::cout<<"Index are not defined along a straight along x or y or z axis."<<std::endl;
-    std::cout<<"The line cannot be extracted."<<std::endl;
-    exit(0);
-  }
-  
   if (args_info.integral_arg!=0){
-    SizeType dim;
-    dim=input->GetLargestPossibleRegion().GetSize();
-    DD(dim);
-    DD(direction);
-    
     int a=0, b=0, c=0;
-    
-    if (direction==2){
-      a=0;
-      b=1;
-      c=2;
+    if (args_info.integralAxis_arg==0){
+       a=1;
+       b=0;
+       c=2;
+    }
+    else if (args_info.integralAxis_arg==1){
+       a=0;
+       b=1;
+       c=2;
+    }
+    else if (args_info.integralAxis_arg==2){
+       a=2;
+       b=0;
+       c=1;
+    }
+    else {std::cout<<"Wrong axis"<<std::endl;
+      exit(0);
     }
-    if (direction==1){
-      a=0;
-      b=2;
-      c=1;
-    }    
-    if (direction==3){
-      a=2;
-      b=0;
-      c=1;
-    } 
-    
-    double val[dim[b]];
-      for (int i=0; i<dim[b]; i++)
-       val[i]=0;
+  
+  length=(lastIndex[b]-firstIndex[b])*spacing[b];
+  
+  std::cout<<"The line is extracted along axis "<<args_info.integralAxis_arg<<std::endl;
+  std::cout<<"The line is integrated between "<<args_info.firstIndex_arg[a]<<" and "<<args_info.lastIndex_arg[a]<<" along axis "<<a<<std::endl;
+  std::cout<<"The line is integrated between "<<args_info.firstIndex_arg[c]<<" and "<<args_info.lastIndex_arg[c]<<" along axis "<<c<<std::endl;
+  
+      SizeType dim;
+      dim=input->GetLargestPossibleRegion().GetSize();
+      DD(dim);
+      DD(direction);
       
-    int k;
-    for (int i=0; i<dim[a]; i++){
-      for (int j=0; j<dim[c]; j++){
-  //      std::cout<<"i "<<i<<"  j "<<j<<std::endl;
-       k=0;
-       firstIndex[a]=i;
-       firstIndex[c]=j;
-       lastIndex[a]=i;
-       lastIndex[c]=j;
-  //      std::cout<<"A"<<std::endl;
-       itk::LineConstIterator<ImageType> iter(input, firstIndex, lastIndex);
-       iter.GoToBegin();
-  //      std::cout<<"B"<<std::endl;
-       val[k]+=iter.Get();
-       k++;
-  //      std::cout<<"C"<<std::endl;
-       while (!iter.IsAtEnd()) {
-  //   std::cout<<"D "<<k<<std::endl;
+      double val[dim[b]];
+       for (int i=0; i<dim[b]; i++)
+         val[i]=0;
+       
+      int k;
+       
+      for (int i=args_info.firstIndex_arg[a]; i<args_info.lastIndex_arg[a]; i++){
+       for (int j=args_info.firstIndex_arg[c]; j<args_info.lastIndex_arg[c]; j++){
+    //      std::cout<<"i "<<i<<"  j "<<j<<std::endl;
+         k=0;
+         firstIndex[a]=i;
+         firstIndex[c]=j;
+         lastIndex[a]=i;
+         lastIndex[c]=j;
+    //      std::cout<<"A"<<std::endl;
+         itk::LineConstIterator<ImageType> iter(input, firstIndex, lastIndex);
+         iter.GoToBegin();
+    //      std::cout<<"B"<<std::endl;
          val[k]+=iter.Get();
-         ++iter;
          k++;
+    //      std::cout<<"C"<<std::endl;
+         while (!iter.IsAtEnd()) {
+    // std::cout<<"D "<<k<<std::endl;
+           val[k]+=iter.Get();
+           ++iter;
+           k++;
+         }
        }
       }
-    }
   
-    for (unsigned int i=0; i<dim[b]; i++){
-      values.push_back(val[i]);
-    }
+      for (unsigned int i=0; i<dim[b]; i++){
+       values.push_back(val[i]);
+      }
   }
   
   double step = length/values.size();
index 96a76ccf56d37a21f9fe71e84a8dff7ef341f5eb..b08438917f9b93c12efa046156f4f8cc05faed1b 100644 (file)
@@ -10,7 +10,8 @@ option "verbose"      v       "Verbose"                         flag          off
 
 option "firstIndex"    f       "First index value (in voxels)"   int yes multiple
 option "lastIndex"     l       "Last index value (in voxels"     int yes multiple
-option "integral"      I       "Integrate the image along the line"    int     no      default = "0"
+option "integral"      I       "Integrate the image along a line"      int     no      default = "0"
+option "integralAxis"  a       "Set the image integration axis"        int     no      default = "0"
 
 option "mm"            m       "Last/first index are in mm"      flag off