X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageCommon.txx;h=e682593751cafc87e6421963e7e8082e0da4da5b;hb=e7f88877b4e3d136e9cfa08613490df94e2728d7;hp=45e8c2e90ecac46fafa0bcf5f0d6bfbfda03296a;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkImageCommon.txx b/common/clitkImageCommon.txx index 45e8c2e..e682593 100644 --- a/common/clitkImageCommon.txx +++ b/common/clitkImageCommon.txx @@ -1,16 +1,23 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ #ifndef CLITKIMAGECOMMON_TXX #define CLITKIMAGECOMMON_TXX -/** - ------------------------------------------------- - * @file clitkImageCommon.txx - * @author David Sarrut - * @date 07 Sep 2007 11:34:19 - * - * @brief - * - * - -------------------------------------------------*/ //-------------------------------------------------------------------- template @@ -80,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) { @@ -126,7 +165,7 @@ typename ImageType::Pointer readImage(const std::vector & filenames //-------------------------------------------------------------------- template -void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose=false) { +void writeImage(const typename ImageType::Pointer image, const std::string & filename, const bool verbose) { typedef itk::ImageFileWriter WriterType; typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(filename.c_str()); @@ -147,7 +186,7 @@ void writeImage(const typename ImageType::Pointer image, const std::string & fil //-------------------------------------------------------------------- template -void writeImage(const ImageType* image, const std::string & filename, const bool verbose=false) { +void writeImage(const ImageType* image, const std::string & filename, const bool verbose) { typedef itk::ImageFileWriter WriterType; typename WriterType::Pointer writer = WriterType::New(); writer->SetFileName(filename.c_str());