]> Creatis software - clitk.git/blobdiff - tools/clitkImageCreate.cxx
changes in license header
[clitk.git] / tools / clitkImageCreate.cxx
index d635eb577f70bdc70c766594514b1b92beddb471..ab2bec514673ced6d5f1313d3477dfa94015feda 100644 (file)
@@ -1,9 +1,9 @@
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-  Authors belong to: 
+  Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
-  - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.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
@@ -14,7 +14,7 @@
 
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
+===========================================================================**/
 #ifndef CLITKIMAGECREATE_CXX
 #define CLITKIMAGECREATE_CXX
 /**
@@ -32,7 +32,7 @@
 
 template<class ImageType>
 void NewFilledImage(int * size, float * spacing, double * origin,
-                   double value,typename ImageType::Pointer output) 
+                    double value,typename ImageType::Pointer output)
 {
   static const unsigned int Dim = ImageType::GetImageDimension();
   typename ImageType::SizeType mSize;
@@ -55,7 +55,8 @@ void NewFilledImage(int * size, float * spacing, double * origin,
 
 
 //--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
+int main(int argc, char * argv[])
+{
 
   // Init command line
   GGO(clitkImageCreate, args_info);
@@ -65,21 +66,21 @@ int main(int argc, char * argv[]) {
   int dim;
   if (args_info.like_given) {
     itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.like_arg);
-     dim = header->GetNumberOfDimensions();
-     //mPixelTypeName = header->GetComponentTypeAsString(header->GetComponentType());  
-     //mNbOfComponents = header->GetNumberOfComponents();
-     args_info.size_given = dim;
-     args_info.size_arg = new int[dim];
-     args_info.spacing_given = dim;
-     args_info.spacing_arg = new float[dim];
-     args_info.origin_given = dim;
-     args_info.origin_arg = new double[dim];
-     
-     for(int i=0; i<dim; i++) {
-       args_info.size_arg[i] = header->GetDimensions(i);
-       args_info.spacing_arg[i] = header->GetSpacing(i);
-       args_info.origin_arg[i]=   header->GetOrigin(i);
-     }
+    dim = header->GetNumberOfDimensions();
+    //mPixelTypeName = header->GetComponentTypeAsString(header->GetComponentType());
+    //mNbOfComponents = header->GetNumberOfComponents();
+    args_info.size_given = dim;
+    args_info.size_arg = new int[dim];
+    args_info.spacing_given = dim;
+    args_info.spacing_arg = new float[dim];
+    args_info.origin_given = dim;
+    args_info.origin_arg = new double[dim];
+
+    for(int i=0; i<dim; i++) {
+      args_info.size_arg[i] = header->GetDimensions(i);
+      args_info.spacing_arg[i] = header->GetSpacing(i);
+      args_info.origin_arg[i]=   header->GetOrigin(i);
+    }
   }
 
   // Check dimension
@@ -88,64 +89,61 @@ int main(int argc, char * argv[]) {
     exit(-1);
   }
   dim = args_info.size_given;
-  
-  // origin 
+
+  // origin
   std::vector<double> origin;
   origin.resize(dim);
   for(int i=0; i<dim; i++) origin[i]=0.;
-  if (args_info.origin_given)
-    {
-      if (args_info.origin_given==1)
-       for(int i=0; i<dim; i++) origin[i] = args_info.origin_arg[0];
-      else 
-       {
-         if (args_info.origin_given != args_info.size_given) {
-           std::cerr << "ERROR : please give the same number of values for --origin and --size." << std::endl;
-           exit(-1);
-         }
-         for(int i=0; i<dim; i++) origin[i] = args_info.origin_arg[i]; 
-       }
+  if (args_info.origin_given) {
+    if (args_info.origin_given==1)
+      for(int i=0; i<dim; i++) origin[i] = args_info.origin_arg[0];
+    else {
+      if (args_info.origin_given != args_info.size_given) {
+        std::cerr << "ERROR : please give the same number of values for --origin and --size." << std::endl;
+        exit(-1);
+      }
+      for(int i=0; i<dim; i++) origin[i] = args_info.origin_arg[i];
     }
+  }
 
-  // spacing 
+  // spacing
   std::vector<float> spacing;
   spacing.resize(dim);
   if (args_info.spacing_given == 1) {
     for(int i=0; i<dim; i++) spacing[i] = args_info.spacing_arg[0];
-  }
-  else {
+  } else {
     if (args_info.spacing_given != args_info.size_given) {
       std::cerr << "ERROR : please give the same number of values for --size and --spacing." << std::endl;
       exit(-1);
     }
     for(int i=0; i<dim; i++) spacing[i] = args_info.spacing_arg[i];
   }
-  
+
   // Create new image
   typedef float PixelType;
   if (dim == 2) {
     const int Dim=2;
-    typedef itk::Image<PixelType, Dim> ImageType; 
+    typedef itk::Image<PixelType, Dim> ImageType;
     ImageType::Pointer output = ImageType::New();
     NewFilledImage<ImageType>(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output);
     clitk::writeImage<ImageType>(output, args_info.output_arg);
   }
   if (dim == 3) {
     const int Dim=3;
-    typedef itk::Image<PixelType, Dim> ImageType; 
+    typedef itk::Image<PixelType, Dim> ImageType;
     ImageType::Pointer output = ImageType::New();
     NewFilledImage<ImageType>(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output);
     clitk::writeImage<ImageType>(output, args_info.output_arg);
   }
   if (dim == 4) {
     const int Dim=4;
-    typedef itk::Image<PixelType, Dim> ImageType; 
+    typedef itk::Image<PixelType, Dim> ImageType;
     ImageType::Pointer output = ImageType::New();
     NewFilledImage<ImageType>(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output);
     clitk::writeImage<ImageType>(output, args_info.output_arg);
   }
-  
-  // this is the end my friend  
+
+  // this is the end my friend
   return 0;
 } // end main