itkExtractImageFilterRegionCopier.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkExtractImageFilterRegionCopier_h
00021 #define __itkExtractImageFilterRegionCopier_h
00022
00023 #include "itkImageToImageFilterDetail.h"
00024
00025 namespace itk
00026 {
00027
00028 namespace ImageToImageFilterDetail
00029 {
00030
00034 template <unsigned int T1, unsigned int T2>
00035 void ExtractImageFilterCopyRegion(const typename
00036 BinaryUnsignedIntDispatch<T1, T2>::FirstEqualsSecondType &firstEqualsSecond,
00037 ImageRegion<T1> &destRegion,
00038 const ImageRegion<T2> &srcRegion,
00039 const ImageRegion<T1> &)
00040 {
00041 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstEqualsSecond, destRegion, srcRegion);
00042 }
00043
00044
00045
00049 template <unsigned int T1, unsigned int T2>
00050 void ExtractImageFilterCopyRegion(const typename
00051 BinaryUnsignedIntDispatch<T1, T2>::FirstLessThanSecondType &firstLessThanSecond,
00052 ImageRegion<T1> &destRegion,
00053 const ImageRegion<T2> &srcRegion,
00054 const ImageRegion<T1> &totalInputExtractionRegion)
00055 {
00056 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstLessThanSecond, destRegion, srcRegion);
00057
00058 }
00059
00060
00077 template <unsigned int T1, unsigned int T2>
00078 void ExtractImageFilterCopyRegion(const typename
00079 BinaryUnsignedIntDispatch<T1, T2>::FirstGreaterThanSecondType &,
00080 ImageRegion<T1> &destRegion,
00081 const ImageRegion<T2> &srcRegion,
00082 const ImageRegion<T1> &totalInputExtractionRegion)
00083 {
00084
00085
00086
00087 unsigned int dim;
00088 Index<T1> destIndex;
00089 Size<T1> destSize;
00090 const Index<T2> &srcIndex = srcRegion.GetIndex();
00091 const Size<T2> &srcSize = srcRegion.GetSize();
00092 int count = 0;
00093 for (dim=0; dim < T1; ++dim)
00094 {
00095
00096 if (!totalInputExtractionRegion.GetSize()[dim])
00097 {
00098 destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
00099 destSize[dim] = 1;
00100 }
00101
00102 else
00103 {
00104 destIndex[dim] = srcIndex[count];
00105 destSize[dim] = srcSize[count];
00106 count++;
00107 }
00108 }
00109 destRegion.SetIndex(destIndex);
00110 destRegion.SetSize(destSize);
00111 }
00113
00131 template <unsigned int T1, unsigned int T2>
00132 class ITK_EXPORT ExtractImageFilterRegionCopier
00133 : public ImageRegionCopier<T1, T2>
00134 {
00135 public:
00136 virtual void operator()(ImageRegion<T1> &destRegion,
00137 const ImageRegion<T2> &srcRegion,
00138 const ImageRegion<T1> &totalInputExtractionRegion) const
00139 {
00140 typedef typename BinaryUnsignedIntDispatch<T1, T2>::ComparisonType ComparisonType;
00141 ExtractImageFilterCopyRegion<T1, T2>(ComparisonType(),
00142 destRegion, srcRegion, totalInputExtractionRegion);
00143 }
00144
00146 virtual void operator() (ImageRegion<T1> &destRegion,
00147 const ImageRegion<T2> &srcRegion) const
00148 {
00149 ImageRegionCopier<T1,T2>::operator()(destRegion, srcRegion);
00150 }
00151 };
00153
00154 }
00155 }
00156
00157 #endif
00158