X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkCommon.txx;h=4d16648fbc020aa025c70b5c46de41c16b330ab3;hb=afd905e344d71097880bef1d1eeeb9aef2541233;hp=984ef76adab1ed8bd3a37ace2e753f36adf00e87;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkCommon.txx b/common/clitkCommon.txx index 984ef76..4d16648 100644 --- a/common/clitkCommon.txx +++ b/common/clitkCommon.txx @@ -128,5 +128,25 @@ std::string GetTypeAsString() { } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void CloneImage(const typename ImageType::Pointer & input, typename ImageType::Pointer & output) { + output->SetRegions(input->GetLargestPossibleRegion()); + output->SetSpacing(input->GetSpacing()); + output->Allocate(); + typedef itk::ImageRegionConstIterator ConstIteratorType; + ConstIteratorType pi(input,input->GetLargestPossibleRegion()); + pi.GoToBegin(); + typedef itk::ImageRegionIterator IteratorType; + IteratorType po(output,input->GetLargestPossibleRegion()); + po.GoToBegin(); + while (!pi.IsAtEnd()) { + po.Set(pi.Get()); + ++pi; + ++po; + } +} +//-------------------------------------------------------------------- + #endif /* end #define CLITKCOMMON_TXX */