| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 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 |
|
| 57 |
typedef AdaptiveNonLocalMeansDenoisingImageFilter Self; |
| 58 |
typedef NonLocalPatchBasedImageFilter<TInputImage, TOutputImage> Superclass; |
| 59 |
typedef SmartPointer<Self> Pointer; |
| 60 |
typedef SmartPointer<const Self> ConstPointer; |
| 61 |
|
| 62 |
|
| 63 |
itkTypeMacro(AdaptiveNonLocalMeansDenoisingImageFilter, NonLocalPatchBasedImageFilter); |
| 64 |
|
| 65 |
|
| 66 |
itkNewMacro(Self); |
| 67 |
|
| 68 |
|
| 69 |
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension); |
| 70 |
|
| 71 |
|
| 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 |
|
| 95 |
|
| 96 |
void |
| 97 |
SetInput1(const InputImageType * image) |
| 98 |
{ |
| 99 |
this->SetInput(image); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 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 |
|
| 119 |
|
| 120 |
|
| 121 |
const MaskImageType * |
| 122 |
GetMaskImage() const |
| 123 |
{ |
| 124 |
return static_cast<const MaskImageType *>(this->ProcessObject::GetInput(1)); |
| 125 |
} |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
itkSetMacro(UseRicianNoiseModel, bool); |
| 132 |
itkGetConstMacro(UseRicianNoiseModel, bool); |
| 133 |
itkBooleanMacro(UseRicianNoiseModel); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
itkSetMacro(SmoothingFactor, RealType); |
| 139 |
itkGetConstMacro(SmoothingFactor, RealType); |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
itkSetMacro(SmoothingVariance, RealType); |
| 145 |
itkGetConstMacro(SmoothingVariance, RealType); |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
itkSetMacro(Epsilon, RealType); |
| 152 |
itkGetConstMacro(Epsilon, RealType); |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
itkSetMacro(MeanThreshold, RealType); |
| 159 |
itkGetConstMacro(MeanThreshold, RealType); |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
itkSetMacro(VarianceThreshold, RealType); |
| 166 |
itkGetConstMacro(VarianceThreshold, RealType); |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 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 |
} |
| 217 |
|
| 218 |
#ifndef ITK_MANUAL_INSTANTIATION |
| 219 |
# include "itkAdaptiveNonLocalMeansDenoisingImageFilter.hxx" |
| 220 |
#endif |
| 221 |
|
| 222 |
#endif |