+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)
+{