Debian Codegraph @

include/itkNonLocalPatchBasedImageFilter.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch 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 #ifndef itkNonLocalPatchBasedImageFilter_h
19 #define itkNonLocalPatchBasedImageFilter_h
20
21 #include <iostream>
22 #include "itkImageToImageFilter.h"
23
24 #include "itkConstNeighborhoodIterator.h"
25
26 namespace itk
27 {
28
29 /**
30 * \class NonLocalPatchBasedImageFilterEnums
31 * \brief Non-local patch-based image filter enum classes.
32 * \ingroup AdaptiveDenoising
33 */
34
35 class NonLocalPatchBasedImageFilterEnums
36 {
37 public:
38 /**\class SimilarityMetric
39 * \brief Neighborhood patch similarity metric enumerated type.
40 * \ingroup AdaptiveDenoising
41 */
42 enum class SimilarityMetric : uint8_t
43 {
44 PEARSON_CORRELATION = 0,
45 MEAN_SQUARES = 1
46 };
47 };
48
•49 extern std::ostream &
50 operator<<(std::ostream & out, const NonLocalPatchBasedImageFilterEnums::SimilarityMetric value);
51
52
53 /**
54 * \class NonLocalPatchBasedImageFilter
55 * \brief Implementation of a non-local image filter.
56 *
57 * \ingroup AdaptiveDenoising
58 */
59
60 template <typename TInputImage, typename TOutputImage = TInputImage>
61 class ITK_TEMPLATE_EXPORT NonLocalPatchBasedImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
62 {
63 public:
64 ITK_DISALLOW_COPY_AND_MOVE(NonLocalPatchBasedImageFilter);
65
66 /** Standard class typedefs. */
67 using Self = NonLocalPatchBasedImageFilter<TInputImage, TOutputImage>;
68 using Superclass = ImageToImageFilter<TInputImage, TOutputImage>;
69 using Pointer = SmartPointer<Self>;
70 using ConstPointer = SmartPointer<const Self>;
71
72 /** Runtime information support. */
73 itkTypeMacro(NonLocalPatchBasedImageFilter, ImageToImageFilter);
74
75 /** Standard New method. */
76 itkNewMacro(Self);
77
78 /** ImageDimension constants */
79 itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
80
81 /** Some convenient typedefs. */
82 using InputImageType = TInputImage;
83 using InputPixelType = typename InputImageType::PixelType;
84 using InputImagePointer = typename InputImageType::Pointer;
85 using InputImageList = std::vector<InputImagePointer>;
86 using InputImageSetList = std::vector<InputImageList>;
87 using RegionType = typename InputImageType::RegionType;
88
89 using OutputImageType = TOutputImage;
90 using OutputPixelType = typename OutputImageType::PixelType;
91
92 using InputImagePixelVectorType = std::vector<InputPixelType>;
93
94 using RealType = float;
95 using RealImageType = Image<RealType, ImageDimension>;
96 using RealImagePointer = typename RealImageType::Pointer;
97 using IndexType = typename RealImageType::IndexType;
98
99 using NeighborhoodType = Neighborhood<InputPixelType, ImageDimension>;
100 using NeighborhoodSizeType = SizeValueType;
101
102 using ConstNeighborhoodIteratorType = ConstNeighborhoodIterator<InputImageType>;
103 using NeighborhoodRadiusType = typename ConstNeighborhoodIteratorType::RadiusType;
104 using NeighborhoodOffsetType = typename ConstNeighborhoodIteratorType::OffsetType;
105
106 using NeighborhoodOffsetListType = std::vector<NeighborhoodOffsetType>;
107
108 using SimilarityMetricEnum = NonLocalPatchBasedImageFilterEnums::SimilarityMetric;
109 #if !defined(ITK_LEGACY_REMOVE)
110 using SimilarityMetricType = SimilarityMetricEnum;
111 static constexpr SimilarityMetricType PEARSON_CORRELATION = SimilarityMetricEnum::PEARSON_CORRELATION;
112 static constexpr SimilarityMetricType MEAN_SQUARES = SimilarityMetricEnum::MEAN_SQUARES;
113 #endif
114
115 /**
116 * Get/set neighborhood search radius.
117 * Default = 3x3x...
118 */
119 itkSetMacro(NeighborhoodSearchRadius, NeighborhoodRadiusType);
120 itkGetConstMacro(NeighborhoodSearchRadius, NeighborhoodRadiusType);
121
122 /**
123 * Get/set neighborhood search size.
124 */
125 itkSetMacro(NeighborhoodSearchSize, NeighborhoodSizeType);
126 itkGetConstMacro(NeighborhoodSearchSize, NeighborhoodSizeType);
127
128 /**
129 * Get/set neighborhood search offset list.
130 */
131 virtual void
132 SetNeighborhoodSearchOffsetList(const NeighborhoodOffsetListType list)
133 {
134 this->m_NeighborhoodSearchOffsetList = list;
135 this->Modified();
136 }
137 itkGetConstMacro(NeighborhoodSearchOffsetList, NeighborhoodOffsetListType);
138
139 /**
140 * Get/set neighborhood patch radius.
141 * Default = 1x1x...
142 */
143 itkSetMacro(NeighborhoodPatchRadius, NeighborhoodRadiusType);
144 itkGetConstMacro(NeighborhoodPatchRadius, NeighborhoodRadiusType);
145
146 /**
147 * Get/set neighborhood patch size.
148 */
149 itkSetMacro(NeighborhoodPatchSize, NeighborhoodSizeType);
150 itkGetConstMacro(NeighborhoodPatchSize, NeighborhoodSizeType);
151
152 /**
153 * Get/set neighborhood patch offset list.
154 */
155 virtual void
156 SetNeighborhoodPatchOffsetList(const NeighborhoodOffsetListType list)
157 {
158 this->m_NeighborhoodPatchOffsetList = list;
159 this->Modified();
160 }
161 itkGetConstMacro(NeighborhoodPatchOffsetList, NeighborhoodOffsetListType);
162
163 /**
164 * Enumerated type for neighborhood similarity. Default = MEAN_SQUARES
165 */
166 itkSetMacro(SimilarityMetric, SimilarityMetricEnum);
167 itkGetConstMacro(SimilarityMetric, SimilarityMetricEnum);
168
169 protected:
170 NonLocalPatchBasedImageFilter();
171 ~NonLocalPatchBasedImageFilter() override = default;
172
173 void
174 BeforeThreadedGenerateData() override;
175
176 void
177 PrintSelf(std::ostream & os, Indent indent) const override;
178
179 RealType
180 ComputeNeighborhoodPatchSimilarity(const InputImageList &,
181 const IndexType,
182 const InputImagePixelVectorType &,
183 const bool);
184
185 InputImagePixelVectorType
186 VectorizeImageListPatch(const InputImageList &, const IndexType, const bool);
187
188 InputImagePixelVectorType
189 VectorizeImagePatch(const InputImagePointer, const IndexType, const bool);
190
191 void
192 GetMeanAndStandardDeviationOfVectorizedImagePatch(const InputImagePixelVectorType &, RealType &, RealType &);
193
194 itkSetMacro(TargetImageRegion, RegionType);
195 itkGetConstMacro(TargetImageRegion, RegionType);
196
197 SimilarityMetricEnum m_SimilarityMetric;
198
199 SizeValueType m_NeighborhoodSearchSize;
200 NeighborhoodRadiusType m_NeighborhoodSearchRadius;
201 NeighborhoodOffsetListType m_NeighborhoodSearchOffsetList;
202
203 SizeValueType m_NeighborhoodPatchSize;
204 NeighborhoodRadiusType m_NeighborhoodPatchRadius;
205 NeighborhoodOffsetListType m_NeighborhoodPatchOffsetList;
206
207 RegionType m_TargetImageRegion;
208 };
209
210 } // end namespace itk
211
212 #ifndef ITK_MANUAL_INSTANTIATION
213 # include "itkNonLocalPatchBasedImageFilter.hxx"
214 #endif
215
216 #endif