]> Creatis software - clitk.git/blobdiff - common/clitkImageCommon.txx
- add CeCILL B licence
[clitk.git] / common / clitkImageCommon.txx
index b1d11226f71997576ebf8d619a02305787f4dc0b..e682593751cafc87e6421963e7e8082e0da4da5b 100644 (file)
 ======================================================================-====*/
 #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>
@@ -96,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) {