ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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
34{
38template <unsigned int T1, unsigned int T2>
39void
41 const typename BinaryUnsignedIntDispatch<T1, T2>::FirstEqualsSecondType & firstEqualsSecond,
42 ImageRegion<T1> & destRegion,
43 const ImageRegion<T2> & srcRegion,
44 const ImageRegion<T1> &)
45{
46 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstEqualsSecond, destRegion, srcRegion);
47}
48
52template <unsigned int T1, unsigned int T2>
53void
55 const typename BinaryUnsignedIntDispatch<T1, T2>::FirstLessThanSecondType & firstLessThanSecond,
56 ImageRegion<T1> & destRegion,
57 const ImageRegion<T2> & srcRegion,
58 const ImageRegion<T1> & itkNotUsed(totalInputExtractionRegion))
59{
60 ImageToImageFilterDefaultCopyRegion<T1, T2>(firstLessThanSecond, destRegion, srcRegion);
61}
62
79template <unsigned int T1, unsigned int T2>
80void
82 ImageRegion<T1> & destRegion,
83 const ImageRegion<T2> & srcRegion,
84 const ImageRegion<T1> & totalInputExtractionRegion)
85{
86 // Source dimension is less than the destination dimension, so look
87 // at the m_TotalExtractionRegion and see what values in size are 0.
88 // With these values, lock the destRegion.Index to the corresponding index
89
90
91 Index<T1> destIndex;
92 Size<T1> destSize;
93 const Index<T2> & srcIndex = srcRegion.GetIndex();
94 const Size<T2> & srcSize = srcRegion.GetSize();
95 int count = 0;
96 for (unsigned int dim = 0; dim < T1; ++dim)
97 {
98 // for dimensions to be removed
99 if (!totalInputExtractionRegion.GetSize()[dim])
100 {
101 destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
102 destSize[dim] = 1;
103 }
104 // for all other dimension
105 else
106 {
107 destIndex[dim] = srcIndex[count];
108 destSize[dim] = srcSize[count];
109 ++count;
110 }
111 }
112 destRegion.SetIndex(destIndex);
113 destRegion.SetSize(destSize);
114}
115
137template <unsigned int T1, unsigned int T2>
138class ITK_TEMPLATE_EXPORT ExtractImageFilterRegionCopier : public ImageRegionCopier<T1, T2>
139{
140public:
141 virtual void
143 const ImageRegion<T2> & srcRegion,
144 const ImageRegion<T1> & totalInputExtractionRegion) const
145 {
146 using ComparisonType = typename BinaryUnsignedIntDispatch<T1, T2>::ComparisonType;
147 ExtractImageFilterCopyRegion<T1, T2>(ComparisonType(), destRegion, srcRegion, totalInputExtractionRegion);
148 }
149
151 void
152 operator()(ImageRegion<T1> & destRegion, const ImageRegion<T2> & srcRegion) const override
153 {
154 ImageRegionCopier<T1, T2>::operator()(destRegion, srcRegion);
155 }
156};
157} // namespace itk::ImageToImageFilterDetail
158
159#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 > &)
void ImageToImageFilterDefaultCopyRegion(const typename BinaryUnsignedIntDispatch< D1, D2 >::FirstEqualsSecondType &, ImageRegion< D1 > &destRegion, const ImageRegion< D2 > &srcRegion)
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