ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkTileMergeImageFilter.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#ifndef itkTileMergeImageFilter_h
20#define itkTileMergeImageFilter_h
21
22#include "itkTileMontage.h"
23
25#include "itkNumericTraits.h"
26
27namespace itk
28{
46template <typename TImageType,
47 typename TPixelAccumulateType = typename NumericTraits<typename TImageType::PixelType>::AccumulateType,
49class ITK_TEMPLATE_EXPORT TileMergeImageFilter
50 : public TileMontage<
51 Image<typename NumericTraits<typename TImageType::PixelType>::ValueType, TImageType::ImageDimension>,
52 typename TInterpolator::CoordinateType>
53{
54public:
55 ITK_DISALLOW_COPY_AND_MOVE(TileMergeImageFilter);
56
58 using Superclass =
60 typename TInterpolator::CoordinateType>;
61
66 using ImageType = TImageType;
67 using ImagePointer = typename ImageType::Pointer;
68 using ImageConstPointer = typename ImageType::ConstPointer;
69
71 itkNewMacro(Self);
72
74 itkOverrideGetNameOfClassMacro(TileMergeImageFilter);
75
77 static constexpr unsigned int ImageDimension = ImageType::ImageDimension;
78
83 void
84 SetMontage(const Superclass * montage);
85
90
92 using PixelType = typename TImageType::PixelType;
98
101 using TransformPointer = typename TransformType::Pointer;
102 using TransformConstPointer = typename TransformType::ConstPointer;
103
105 void
106 SetReleaseDataFlag(bool flag) override
107 {
109 }
110
112 void
113 SetReleaseDataBeforeUpdateFlag(const bool flag) override
114 {
116 }
117
120 ImageType *
122 const ImageType *
123 GetOutput() const;
124 ImageType *
125 GetOutput(unsigned int idx);
126
128 void
130
133 void
135 {
136 // image will be cast into DataObject* so this casting is not a problem
137 Superclass::SetInputTile(linearIndex, reinterpret_cast<typename Superclass::ImageType *>(image));
138 m_Transforms[linearIndex] = nullptr;
139 m_Tiles[linearIndex] = nullptr;
140 }
141 void
142 SetInputTile(SizeValueType linearIndex, const std::string & imageFilename)
143 {
144 Superclass::SetInputTile(linearIndex, imageFilename);
145 m_Transforms[linearIndex] = nullptr;
146 m_Tiles[linearIndex] = nullptr;
147 }
148 void
150 {
151 this->SetInputTile(this->nDIndexToLinearIndex(position), image);
152 }
153 void
154 SetInputTile(TileIndexType position, const std::string & imageFilename)
155 {
156 this->SetInputTile(this->nDIndexToLinearIndex(position), imageFilename);
157 }
158
162 void
163 SetTileTransform(TileIndexType position, const TransformType * transform);
164
167 itkSetMacro(Background, PixelType);
168 itkGetMacro(Background, PixelType);
169
175 itkSetMacro(CropToFill, bool);
176 itkGetMacro(CropToFill, bool);
177 itkBooleanMacro(CropToFill);
178
179protected:
181 ~TileMergeImageFilter() override = default;
182 void
183 PrintSelf(std::ostream & os, Indent indent) const override;
184
186 void
187 GenerateData() override;
188
190 void
192
194
197 {
198 return ImageType::New();
199 }
200
204 ImageConstPointer
205 GetImage(TileIndexType nDIndex, RegionType wantedRegion);
206
208 using ContributingTiles = std::set<SizeValueType>;
209
210 void
211 SplitRegionAndCopyContributions(std::vector<RegionType> & regions,
212 std::vector<ContributingTiles> & regionContributors,
213 RegionType newRegion,
214 size_t oldRegionIndex,
215 SizeValueType tileIndex);
216
221
225
229 void
231
232private:
233 bool m_CropToFill = false; // crop to avoid background filling?
234 PixelType m_Background = PixelType(); // default background value (not covered by any input tile)
235
236 std::vector<TransformConstPointer> m_Transforms;
237 std::vector<ImagePointer> m_Tiles; // metadata/image storage (if filenames are given instead of actual images)
239 std::vector<RegionType> m_InputMappings; // where do input tile regions map into the output
240 std::vector<ContinuousIndexType> m_InputsContinuousIndices; // where do input tile region indices map into the output
241 std::vector<RegionType> m_Regions; // regions which completely cover the output,
242 // grouped by the set of contributing input tiles
243 std::vector<ContributingTiles> m_RegionContributors; // set of input tiles which contribute to corresponding regions
244}; // class TileMergeImageFilter
245
246} // namespace itk
247
248#ifndef ITK_MANUAL_INSTANTIATION
249# include "itkTileMergeImageFilter.hxx"
250#endif
251
252#endif // itkTileMergeImageFilter_h
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition itkIndent.h:53
Linearly interpolate an image at specified positions.
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
virtual void SetReleaseDataBeforeUpdateFlag(bool _arg)
virtual void SetReleaseDataFlag(bool val)
Implements transparent reference counting.
typename Superclass::PCMType::TransformType TransformType
SizeValueType DistanceFromEdge(ImageIndexType index, RegionType region)
void SetInputTile(TileIndexType position, const std::string &imageFilename)
ImageConstPointer GetImage(TileIndexType nDIndex, RegionType wantedRegion)
void SetTileTransform(TileIndexType position, const TransformType *transform)
typename Superclass::RegionType RegionType
Superclass::ConstPointer m_Montage
typename TransformType::Pointer TransformPointer
void ResampleSingleRegion(SizeValueType regionIndex)
std::vector< ContinuousIndexType > m_InputsContinuousIndices
typename Superclass::OffsetType OffsetType
typename ImageType::ConstPointer ImageConstPointer
typename Superclass::ImageIndexType ImageIndexType
const ImageType * GetOutput() const
std::vector< ContributingTiles > m_RegionContributors
SmartPointer< const Self > ConstPointer
static constexpr unsigned int ImageDimension
TileMontage< Image< typename NumericTraits< typename TImageType::PixelType >::ValueType, TImageType::ImageDimension >, typename TInterpolator::CoordinateType > Superclass
std::vector< ImagePointer > m_Tiles
void SetReleaseDataFlag(bool flag) override
std::vector< RegionType > m_InputMappings
typename TImageType::PixelType PixelType
void SplitRegionAndCopyContributions(std::vector< RegionType > &regions, std::vector< ContributingTiles > &regionContributors, RegionType newRegion, vcl_size_t oldRegionIndex, SizeValueType tileIndex)
void SetReleaseDataBeforeUpdateFlag(const bool flag) override
typename Superclass::PointType PointType
DataObject::Pointer MakeOutput(typename Superclass::DataObjectPointerArraySizeType) override
~TileMergeImageFilter() override=default
void SetMontageSize(SizeType montageSize)
void SetMontage(const Superclass *montage)
typename ImageType::Pointer ImagePointer
typename Superclass::TileIndexType TileIndexType
void GenerateOutputInformation() override
typename Superclass::SizeType SizeType
std::set< SizeValueType > ContributingTiles
void SetInputTile(TileIndexType position, ImageType *image)
typename Superclass::SpacingType SpacingType
void SetInputTile(SizeValueType linearIndex, const std::string &imageFilename)
std::vector< TransformConstPointer > m_Transforms
ImageType * GetOutput(unsigned int idx)
RegionType ConstructRegion(ContinuousIndexType minIndex, ContinuousIndexType maxIndex)
typename Superclass::ContinuousIndexType ContinuousIndexType
void PrintSelf(std::ostream &os, Indent indent) const override
void SetInputTile(SizeValueType linearIndex, ImageType *image)
std::vector< RegionType > m_Regions
void GenerateData() override
typename TransformType::ConstPointer TransformConstPointer
DataObjectPointerArraySizeType nDIndexToLinearIndex(TileIndexType nDIndex) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:82
#define itkSetMacro(name, type)