From: Romulo Pinho Date: Tue, 21 Feb 2012 14:36:40 +0000 (+0100) Subject: Merge branch 'master' of git.creatis.insa-lyon.fr:clitk X-Git-Tag: v1.3.0~92 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=b449b21225742bcca0953edce7987c9fae44020b;hp=5398fcd33c0271a2adef4c2cc299cd0597818ffb;p=clitk.git Merge branch 'master' of git.creatis.insa-lyon.fr:clitk --- diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index e15e6d7..6a4333f 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include @@ -36,7 +36,12 @@ template void vvImageReader::UpdateWithDim(std::string InputPixelType) { if (mType == VECTORFIELD || mType == VECTORFIELDWITHTIME) - UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + { + if (VImageDimension == 4) + UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + else + UpdateWithDimAndInputVectorPixelType,VImageDimension>(); + } else if (InputPixelType == "short") UpdateWithDimAndInputPixelType(); else if (InputPixelType == "unsigned_short") @@ -235,14 +240,15 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() } analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } - + typedef itk::Image< itk::Vector, VImageDimension > VectorImageType; - typedef itk::VectorCastImageFilter CasterType; + typedef itk::FlexibleVectorCastImageFilter CasterType; typename VectorImageType::Pointer casted_input; typename CasterType::Pointer caster = CasterType::New(); caster->SetInput(input); + caster->Update(); casted_input = caster->GetOutput(); - + mImage = vvImageFromITK >(casted_input, mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME); // For unknown analyze orientations, we set identity diff --git a/itk/itkFlexibleBinaryFunctorImageFilter.h b/itk/itkFlexibleBinaryFunctorImageFilter.h index c51ab0c..18062a2 100644 --- a/itk/itkFlexibleBinaryFunctorImageFilter.h +++ b/itk/itkFlexibleBinaryFunctorImageFilter.h @@ -145,8 +145,13 @@ protected: * * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ +#if ITK_VERSION_MAJOR >= 4 + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + itk::ThreadIdType threadId ); +#else void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId ); +#endif private: FlexibleBinaryFunctorImageFilter(const Self&); //purposely not implemented diff --git a/itk/itkFlexibleBinaryFunctorImageFilter.txx b/itk/itkFlexibleBinaryFunctorImageFilter.txx index 0914787..f8c7a75 100644 --- a/itk/itkFlexibleBinaryFunctorImageFilter.txx +++ b/itk/itkFlexibleBinaryFunctorImageFilter.txx @@ -98,7 +98,11 @@ template ::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, +#if ITK_VERSION_MAJOR >= 4 + itk::ThreadIdType threadId ) +#else int threadId) +#endif { const unsigned int dim = Input1ImageType::ImageDimension; diff --git a/itk/itkFlexibleVectorCastImageFilter.h b/itk/itkFlexibleVectorCastImageFilter.h new file mode 100644 index 0000000..1e73a92 --- /dev/null +++ b/itk/itkFlexibleVectorCastImageFilter.h @@ -0,0 +1,113 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkFlexibleVectorCastImageFilter.h,v $ + Language: C++ + Date: $Date: 2008-10-17 16:30:53 $ + Version: $Revision: 1.16 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkFlexibleVectorCastImageFilter_h +#define __itkFlexibleVectorCastImageFilter_h + +#include "itkUnaryFunctorImageFilter.h" +#include "itkNumericTraitsFixedArrayPixel.h" + +namespace itk +{ + +/** \class FlexibleVectorCastImageFilter + * + * \brief Casts input vector pixels to output vector pixel type. + * + * This filter is templated over the input image type and + * output image type. + * + * The filter expect both images to have the same number of dimensions, + * and that both the input and output have itk::Vector pixel types + * of the same VectorDimension. + * + * \sa Vector + * + * \ingroup IntensityImageFilters Multithreaded + */ +namespace Functor { + +template< class TInput, class TOutput> +class FlexibleVectorCast +{ +public: + FlexibleVectorCast() {} + ~FlexibleVectorCast() {} + bool operator!=( const FlexibleVectorCast & ) const + { + return false; + } + bool operator==( const FlexibleVectorCast & other ) const + { + return !(*this != other); + } + inline TOutput operator()( const TInput & A ) const + { + typedef typename TOutput::ValueType OutputValueType; + + TOutput value; + unsigned int k; + for( k = 0; k < TOutput::Dimension && k < TInput::Dimension; k++ ) + { + value[k] = static_cast( A[k] ); + } + + for (; k < TOutput::Dimension; k++) + value[k] = 0; + + return value; + } +}; +} + +template > +class ITK_EXPORT FlexibleVectorCastImageFilter : + public +UnaryFunctorImageFilter > +{ +public: + /** Standard class typedefs. */ + typedef FlexibleVectorCastImageFilter Self; + typedef UnaryFunctorImageFilter< + TInputImage,TOutputImage, + Functor::FlexibleVectorCast< typename TInputImage::PixelType, + typename TOutputImage::PixelType> > Superclass; + typedef SmartPointer Pointer; + typedef SmartPointer ConstPointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Runtime information support. */ + itkTypeMacro(FlexibleVectorCastImageFilter, + UnaryFunctorImageFilter); + +protected: + FlexibleVectorCastImageFilter() {} + virtual ~FlexibleVectorCastImageFilter() {} + +private: + FlexibleVectorCastImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + +}; + +} // end namespace itk + + +#endif