Debian Codegraph @

include/itkAdaptiveNonLocalMeansDenoisingImageFilter.h

raw symbols SCIP
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 itkAdaptiveNonLocalMeansDenoisingImageFilter_h
19 #define itkAdaptiveNonLocalMeansDenoisingImageFilter_h
20
21 #include "itkNonLocalPatchBasedImageFilter.h"
22
23 #include "itkConstNeighborhoodIterator.h"
24 #include "itkGaussianOperator.h"
25
26 namespace itk
27 {
28
29 /**
30 * \class AdaptiveNonLocalMeansDenoisingImageFilter
31 * \brief Implementation of a denoising image filter.
32 *
33 * \author Jose V. Manjon with ITK porting by Nick Tustison
34 *
35 * Contributed by
36 *
37 * \par REFERENCE
38 *
39 * J. V. Manjon, P. Coupe, Luis Marti-Bonmati, D. L. Collins,
40 * and M. Robles. "Adaptive Non-Local Means Denoising of MR Images With
41 * Spatially Varying Noise Levels, Journal of Magnetic Resonance Imaging,
42 * 31:192-203, June 2010.
43 *
44 * \ingroup AdaptiveDenoising
45 */
46
47 template <typename TInputImage,
48 typename TOutputImage = TInputImage,
49 typename TMaskImage = Image<unsigned char, TInputImage::ImageDimension>>
50 class ITK_TEMPLATE_EXPORT AdaptiveNonLocalMeansDenoisingImageFilter final
51 : public NonLocalPatchBasedImageFilter<TInputImage, TOutputImage>
52 {
53 public:
54 ITK_DISALLOW_COPY_AND_MOVE(AdaptiveNonLocalMeansDenoisingImageFilter);
55
56 /** Standard class typedefs. */
57 typedef AdaptiveNonLocalMeansDenoisingImageFilter Self;
58 typedef NonLocalPatchBasedImageFilter<TInputImage, TOutputImage> Superclass;
59 typedef SmartPointer<Self> Pointer;
60 typedef SmartPointer<const Self> ConstPointer;
61
62 /** Runtime information support. */
63 itkTypeMacro(AdaptiveNonLocalMeansDenoisingImageFilter, NonLocalPatchBasedImageFilter);
64
65 /** Standard New method. */
66 itkNewMacro(Self);
67
68 /** ImageDimension constants */
69 itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
70
71 /** Some convenient typedefs. */
72 typedef TInputImage InputImageType;
73 typedef typename InputImageType::PixelType InputPixelType;
74 typedef TOutputImage OutputImageType;
75 typedef typename Superclass::RegionType RegionType;
76
77 typedef TMaskImage MaskImageType;
78 typedef typename MaskImageType::PixelType MaskPixelType;
79 typedef typename MaskImageType::PixelType LabelType;
80
81 typedef typename Superclass::RealType RealType;
82 typedef typename Superclass::RealImageType RealImageType;
83 typedef typename Superclass::RealImagePointer RealImagePointer;
84 typedef typename Superclass::IndexType IndexType;
85
86 typedef typename Superclass::ConstNeighborhoodIteratorType ConstNeighborhoodIteratorType;
87 typedef typename Superclass::NeighborhoodRadiusType NeighborhoodRadiusType;
88 typedef typename Superclass::NeighborhoodOffsetType NeighborhoodOffsetType;
89 typedef typename Superclass::NeighborhoodOffsetListType NeighborhoodOffsetListType;
90
91 typedef GaussianOperator<RealType> ModifiedBesselCalculatorType;
92
93 /**
94 * The image expected for input for noise correction.
95 */
96 void
97 SetInput1(const InputImageType * image)
98 {
99 this->SetInput(image);
100 }
101
102 /**
103 * Set mask image function. If a binary mask image is specified, only
104 * those input image voxels corresponding with the mask image.
105 */
106 void
107 SetMaskImage(const MaskImageType * mask)
108 {
109 this->SetNthInput(1, const_cast<MaskImageType *>(mask));
110 }
111 void
112 SetInput2(const MaskImageType * mask)
113 {
114 this->SetMaskImage(mask);
115 }
116
117 /**
118 * Get mask image function. If a binary mask image is specified, only
119 * those input image voxels corresponding with the mask image.
120 */
121 const MaskImageType *
122 GetMaskImage() const
123 {
124 return static_cast<const MaskImageType *>(this->ProcessObject::GetInput(1));
125 }
126
127 /**
128 * Employ Rician noise model. Otherwise use a Gaussian noise model.
129 * Default = true.
130 */
131 itkSetMacro(UseRicianNoiseModel, bool);
132 itkGetConstMacro(UseRicianNoiseModel, bool);
133 itkBooleanMacro(UseRicianNoiseModel);
134
135 /**
136 * Smoothing factor for noise. Default = 1.0.
137 */
138 itkSetMacro(SmoothingFactor, RealType);
139 itkGetConstMacro(SmoothingFactor, RealType);
140
141 /**
142 * Smoothing variance for Rician noise. Default = 2.0.
143 */
144 itkSetMacro(SmoothingVariance, RealType);
145 itkGetConstMacro(SmoothingVariance, RealType);
146
147 /**
148 * Epsilon for minimum value of mean and variance at a pixel.
149 * Default = 0.00001.
150 */
151 itkSetMacro(Epsilon, RealType);
152 itkGetConstMacro(Epsilon, RealType);
153
154 /**
155 * Mean threshold.
156 * Default = 0.95.
157 */
158 itkSetMacro(MeanThreshold, RealType);
159 itkGetConstMacro(MeanThreshold, RealType);
160
161 /**
162 * Variance threshold.
163 * Default = 0.5.
164 */
165 itkSetMacro(VarianceThreshold, RealType);
166 itkGetConstMacro(VarianceThreshold, RealType);
167
168 /**
169 * Neighborhood for computing local mean and variance images.
170 * Default = 1x1x...
171 */
172 itkSetMacro(NeighborhoodRadiusForLocalMeanAndVariance, NeighborhoodRadiusType);
173 itkGetConstMacro(NeighborhoodRadiusForLocalMeanAndVariance, NeighborhoodRadiusType);
174
175 protected:
176 AdaptiveNonLocalMeansDenoisingImageFilter();
177 ~AdaptiveNonLocalMeansDenoisingImageFilter() override = default;
178
179 void
180 PrintSelf(std::ostream & os, Indent indent) const override;
181
182 void
183 ThreadedGenerateData(const RegionType &, ThreadIdType) override;
184
185 void
186 BeforeThreadedGenerateData() override;
187
188 void
189 AfterThreadedGenerateData() override;
190
191 private:
192 RealType CalculateCorrectionFactor(RealType);
193
194 bool m_UseRicianNoiseModel;
195
196 ModifiedBesselCalculatorType m_ModifiedBesselCalculator;
197
198 RealType m_Epsilon;
199 RealType m_MeanThreshold;
200 RealType m_VarianceThreshold;
201 RealType m_SmoothingFactor;
202 RealType m_SmoothingVariance;
203
204 RealType m_MaximumInputPixelIntensity;
205 RealType m_MinimumInputPixelIntensity;
206
207 RealImagePointer m_MeanImage;
208 RealImagePointer m_RicianBiasImage;
209 RealImagePointer m_VarianceImage;
210 RealImagePointer m_ThreadContributionCountImage;
211 RealImagePointer m_IntensitySquaredDistanceImage;
212
213 NeighborhoodRadiusType m_NeighborhoodRadiusForLocalMeanAndVariance;
214 };
215
216 } // end namespace itk
217
218 #ifndef ITK_MANUAL_INSTANTIATION
219 # include "itkAdaptiveNonLocalMeansDenoisingImageFilter.hxx"
220 #endif
221
222 #endif