ITK  6.0.0
Insight Toolkit
itkExtractImageFilterRegionCopier.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18/*=========================================================================
19 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkExtractImageFilterRegionCopier_h
29#define itkExtractImageFilterRegionCopier_h
30
32
33namespace itk
34{
35namespace ImageToImageFilterDetail
36{
40template <unsigned int T1, unsigned int T2>
41void
43 const typename BinaryUnsignedIntDispatch<T1, T2>::FirstEqualsSecondType & firstEqualsSecond,
44 ImageRegion<T1> & destRegion,
45 const ImageRegion<T2> & srcRegion,
46 const ImageRegion<T1> &)
47{
48 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstEqualsSecond, destRegion, srcRegion);
49}
50
54template <unsigned int T1, unsigned int T2>
55void
57 const typename BinaryUnsignedIntDispatch<T1, T2>::FirstLessThanSecondType & firstLessThanSecond,
58 ImageRegion<T1> & destRegion,
59 const ImageRegion<T2> & srcRegion,
60 const ImageRegion<T1> & itkNotUsed(totalInputExtractionRegion))
61{
62 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstLessThanSecond, destRegion, srcRegion);
63}
64
81template <unsigned int T1, unsigned int T2>
82void
84 ImageRegion<T1> & destRegion,
85 const ImageRegion<T2> & srcRegion,
86 const ImageRegion<T1> & totalInputExtractionRegion)
87{
88 // Source dimension is less than the destination dimension, so look
89 // at the m_TotalExtractionRegion and see what values in size are 0.
90 // With these values, lock the destRegion.Index to the corresponding index
91 unsigned int dim;
92
93 Index<T1> destIndex;
94 Size<T1> destSize;
95 const Index<T2> & srcIndex = srcRegion.GetIndex();
96 const Size<T2> & srcSize = srcRegion.GetSize();
97 int count = 0;
98 for (dim = 0; dim < T1; ++dim)
99 {
100 // for dimensions to be removed
101 if (!totalInputExtractionRegion.GetSize()[dim])
102 {
103 destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
104 destSize[dim] = 1;
105 }
106 // for all other dimension
107 else
108 {
109 destIndex[dim] = srcIndex[count];
110 destSize[dim] = srcSize[count];
111 ++count;
112 }
113 }
114 destRegion.SetIndex(destIndex);
115 destRegion.SetSize(destSize);
116}
117
139template <unsigned int T1, unsigned int T2>
140class ITK_TEMPLATE_EXPORT ExtractImageFilterRegionCopier : public ImageRegionCopier<T1, T2>
141{
142public:
143 virtual void
145 const ImageRegion<T2> & srcRegion,
146 const ImageRegion<T1> & totalInputExtractionRegion) const
147 {
148 using ComparisonType = typename BinaryUnsignedIntDispatch<T1, T2>::ComparisonType;
149 ExtractImageFilterCopyRegion<T1, T2>(ComparisonType(), destRegion, srcRegion, totalInputExtractionRegion);
150 }
151
153 void
154 operator()(ImageRegion<T1> & destRegion, const ImageRegion<T2> & srcRegion) const override
155 {
156 ImageRegionCopier<T1, T2>::operator()(destRegion, srcRegion);
157 }
158};
159} // end namespace ImageToImageFilterDetail
160} // end namespace itk
163#endif
An image region represents a structured region of data.
void SetSize(const SizeType &size)
const IndexType & GetIndex() const
void SetIndex(const IndexType &index)
const SizeType & GetSize() const
A special variation of ImageRegionCopier for when the output image has fewer dimensions than the inpu...
virtual void operator()(ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion, const ImageRegion< T1 > &totalInputExtractionRegion) const
void operator()(ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion) const override
A Function object used to dispatching to a routine to copy a region (start index and size).
virtual void operator()(ImageRegion< D1 > &destRegion, const ImageRegion< D2 > &srcRegion) const
void ExtractImageFilterCopyRegion(const typename BinaryUnsignedIntDispatch< T1, T2 >::FirstEqualsSecondType &firstEqualsSecond, ImageRegion< T1 > &destRegion, const ImageRegion< T2 > &srcRegion, const ImageRegion< T1 > &)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Templated class to produce a unique type for each integer.
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:69
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:70