ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMirrorPadImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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  * http://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 #ifndef itkMirrorPadImageFilter_h
19 #define itkMirrorPadImageFilter_h
20 
21 #include "itkPadImageFilter.h"
22 #include "itkNumericTraits.h"
23 #include <vector>
24 
25 namespace itk
26 {
27 
57 template< typename TInputImage, typename TOutputImage >
58 class ITK_TEMPLATE_EXPORT MirrorPadImageFilter:
59  public PadImageFilter< TInputImage, TOutputImage >
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_ASSIGN(MirrorPadImageFilter);
63 
69 
71  itkNewMacro(Self);
72 
74  itkTypeMacro(MirrorPadImageFilter, PadImageFilter);
75 
76  using InputImageType = TInputImage;
77  using OutputImageType = TOutputImage;
78 
80  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
81  using InputImageRegionType = typename Superclass::InputImageRegionType;
82 
84  using OutputImagePixelType = typename Superclass::OutputImagePixelType;
85  using InputImagePixelType = typename Superclass::InputImagePixelType;
86 
88  using OutputImageIndexType = typename Superclass::OutputImageIndexType;
89  using InputImageIndexType = typename Superclass::InputImageIndexType;
90  using OutputImageSizeType = typename Superclass::OutputImageSizeType;
91  using InputImageSizeType = typename Superclass::InputImageSizeType;
92 
94  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
95 
97  itkGetMacro(DecayBase, double);
98  itkSetClampMacro( DecayBase, double, NumericTraits<double>::min(), 1.0);
100 
101 #ifdef ITK_USE_CONCEPT_CHECKING
102  // Begin concept checking
103  itkConceptMacro( InputConvertibleToOutputCheck,
105  // End concept checking
106 #endif
107 
108 protected:
109  MirrorPadImageFilter() = default;
110  ~MirrorPadImageFilter() override = default;
111 
112 
115  void ConvertOutputIndexToInputIndex(OutputImageIndexType & outputIndex,
116  InputImageIndexType & inputIndex,
117  OutputImageRegionType & outputRegion,
118  InputImageRegionType & inputRegion,
119  int *oddRegionArray,
120  IndexValueType & distanceFromEdge);
121 
122  void ConvertOutputIndexToInputIndex(OutputImageIndexType & outputIndex,
123  InputImageIndexType & inputIndex,
124  OutputImageRegionType & outputRegion,
125  InputImageRegionType & inputRegion,
126  int *oddRegionArray,
127  double & outDecayFactor );
128 
131  int RegionIsOdd(long base, long test, long size);
132 
143  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
144 
145 
149  int GenerateNextInputRegion(long *regIndices, long *regLimit,
150  std::vector< long > *indices,
151  std::vector< long > *sizes,
152  InputImageRegionType & outputRegion);
153 
157  int GenerateNextOutputRegion(long *regIndices, long *regLimit,
158  std::vector< long > *indices,
159  std::vector< long > *sizes,
160  OutputImageRegionType & outputRegion);
161 
166  int FindRegionsInArea(long start, long end, long size, long offset);
167 
174  int BuildInterRegions(std::vector< long > & inputRegionStart,
175  std::vector< long > & outputRegionStart,
176  std::vector< long > & inputRegionSizes,
177  std::vector< long > & outputRegionSizes,
178  long inputIndex, long outputIndex,
179  long inputSize, long outputSize, int numRegs,
180  int & regCtr);
181 
190  int BuildPreRegions(std::vector< long > & inputRegionStart,
191  std::vector< long > & outputRegionStart,
192  std::vector< long > & inputRegionSizes,
193  std::vector< long > & outputRegionSizes,
194  long inputIndex, long outputIndex,
195  long inputSize, long outputSize, int numRegs,
196  int & regCtr);
197 
206  int BuildPostRegions(std::vector< long > & inputRegionStart,
207  std::vector< long > & outputRegionStart,
208  std::vector< long > & inputRegionSizes,
209  std::vector< long > & outputRegionSizes,
210  long inputIndex, long outputIndex,
211  long inputSize, long outputSize,
212  int numRegs, int & regCtr);
213 
221  void GenerateInputRequestedRegion() override;
222 
223 private:
224  double m_DecayBase = 1.0;
225 };
226 } // end namespace itk
227 
228 #ifndef ITK_MANUAL_INSTANTIATION
229 #include "itkMirrorPadImageFilter.hxx"
230 #endif
231 
232 #endif
Define numeric traits for std::vector.
typename Superclass::InputImageIndexType InputImageIndexType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename Superclass::OutputImageSizeType OutputImageSizeType
typename OutputImageType::RegionType OutputImageRegionType
typename Superclass::InputImageSizeType InputImageSizeType
TOutputImage OutputImageType
signed long IndexValueType
Definition: itkIntTypes.h:90
typename InputImageType::RegionType InputImageRegionType
Increase the image size by padding with replicants of the input image value.
Increase the image size by padding. Superclass for filters that fill in extra pixels.
#define itkConceptMacro(name, concept)
int test(char *INfilename, char *OUTfilename, bool IsBinary)
typename Superclass::OutputImageIndexType OutputImageIndexType