X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageCommon.txx;h=e682593751cafc87e6421963e7e8082e0da4da5b;hb=13bdf85dd7480e31735f711c600411db4db653ba;hp=b1d11226f71997576ebf8d619a02305787f4dc0b;hpb=0b7c9b1e1215634b02cbd38d4e4ba101d6111ba8;p=clitk.git diff --git a/common/clitkImageCommon.txx b/common/clitkImageCommon.txx index b1d1122..e682593 100644 --- a/common/clitkImageCommon.txx +++ b/common/clitkImageCommon.txx @@ -17,16 +17,7 @@ ======================================================================-====*/ #ifndef CLITKIMAGECOMMON_TXX #define CLITKIMAGECOMMON_TXX -/** - ------------------------------------------------- - * @file clitkImageCommon.txx - * @author David Sarrut - * @date 07 Sep 2007 11:34:19 - * - * @brief - * - * - -------------------------------------------------*/ + //-------------------------------------------------------------------- template @@ -96,6 +87,38 @@ typename itk::Image::Pointer NewImage4D(int sx, int sy, int sz, int } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +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 +void CopyValues(const typename ImageType::Pointer input, + typename ImageType::Pointer output) { + 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; + } +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template typename ImageType::Pointer readImage(const std::string & filename, const bool verbose) {