X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=common%2FclitkCommon.txx;h=2441dcd2b27727bbe8cc62f43bd8b3c6018d39bb;hb=ec98e4a8aed11c9daa9bd7e2439d1ac489c933c7;hp=984ef76adab1ed8bd3a37ace2e753f36adf00e87;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkCommon.txx b/common/clitkCommon.txx index 984ef76..2441dcd 100644 --- a/common/clitkCommon.txx +++ b/common/clitkCommon.txx @@ -112,6 +112,9 @@ void GetSortedIndex(const std::vector & toSort, std::vector & index, //-------------------------------------------------------------------- template std::string GetTypeAsString() { + // http://www.vtk.org/doc/release/3/html/vtkSetGet_8h-source.html + // and + // itkImageIOBase.cxx const std::type_info & PixType = typeid(TPixel); std::string pixelName; if (PixType == typeid(char)) pixelName = "char"; // 'plain" char is different from signed char and unsigned char ... @@ -128,5 +131,26 @@ std::string GetTypeAsString() { } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void CloneImage(const typename ImageType::Pointer & input, typename ImageType::Pointer & output) { + output->SetRegions(input->GetLargestPossibleRegion()); + output->SetOrigin(input->GetOrigin()); + 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 */