]> Creatis software - clitk.git/blobdiff - common/clitkImageCommon.txx
- add CeCILL B licence
[clitk.git] / common / clitkImageCommon.txx
index 45e8c2e90ecac46fafa0bcf5f0d6bfbfda03296a..e682593751cafc87e6421963e7e8082e0da4da5b 100644 (file)
@@ -1,16 +1,23 @@
+/*=========================================================================
+  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 CLITKIMAGECOMMON_TXX
 #define CLITKIMAGECOMMON_TXX
 
-/**
-   -------------------------------------------------
-   * @file   clitkImageCommon.txx
-   * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
-   * @date   07 Sep 2007 11:34:19
-   * 
-   * @brief  
-   * 
-   * 
-   -------------------------------------------------*/
 
 //--------------------------------------------------------------------
 template<class PixelType>
@@ -80,6 +87,38 @@ typename itk::Image<PixelType,4>::Pointer NewImage4D(int sx, int sy, int sz, int
 }
 //--------------------------------------------------------------------
 
+
+//--------------------------------------------------------------------
+template<class ImageType>
+typename ImageType::Pointer NewImageLike(const typename ImageType::Pointer input, bool allocate) {
+  typename ImageType::Pointer output = ImageType::New();
+  output->CopyInformation(input);
+  output->SetRegions(input->GetLargestPossibleRegion());  
+  if (allocate) output->Allocate();
+  return output;
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class ImageType>
+void CopyValues(const typename ImageType::Pointer input, 
+                typename ImageType::Pointer output) {  
+  typedef itk::ImageRegionConstIterator<ImageType> ConstIteratorType; 
+  ConstIteratorType pi(input,input->GetLargestPossibleRegion());
+  pi.GoToBegin();  
+  typedef itk::ImageRegionIterator<ImageType> IteratorType; 
+  IteratorType po(output,input->GetLargestPossibleRegion());
+  po.GoToBegin(); 
+  while (!pi.IsAtEnd()) {
+    po.Set(pi.Get());
+    ++pi;
+    ++po;
+  }
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 template<class ImageType>
 typename ImageType::Pointer readImage(const std::string & filename, const bool verbose) {
@@ -126,7 +165,7 @@ typename ImageType::Pointer readImage(const std::vector<std::string> & filenames
 
 //--------------------------------------------------------------------
 template<class ImageType>
-void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose=false) {
+void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose) {
   typedef itk::ImageFileWriter<ImageType> WriterType;
   typename WriterType::Pointer writer = WriterType::New();
   writer->SetFileName(filename.c_str());
@@ -147,7 +186,7 @@ void writeImage(const typename ImageType::Pointer image, const std::string & fil
 
 //--------------------------------------------------------------------
 template<class ImageType>
-void writeImage(const ImageType* image, const std::string & filename, const bool verbose=false) {
+void writeImage(const ImageType* image, const std::string & filename, const bool verbose) {
   typedef itk::ImageFileWriter<ImageType> WriterType;
   typename WriterType::Pointer writer = WriterType::New();
   writer->SetFileName(filename.c_str());