digiKam
nrfilter.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2005-05-25
7  * Description : Wavelets Noise Reduction threaded image filter.
8  * This filter work in YCrCb color space.
9  *
10  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_NR_FILTER_H
27 #define DIGIKAM_NR_FILTER_H
28 
29 // Qt includes
30 
31 #include <QMetaType>
32 #include <QDebug>
33 
34 // Local includes
35 
36 #include "digikam_export.h"
37 #include "dimgthreadedfilter.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT NRContainer
43 {
44 
45 public:
46 
47  explicit NRContainer();
48  ~NRContainer();
49 
50 public:
51 
55  double thresholds[3];
56  double softness[3];
57 };
58 
60 DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const NRContainer& inf);
61 
62 // --------------------------------------------------------------------------
63 
64 class DIGIKAM_EXPORT NRFilter : public DImgThreadedFilter
65 {
66  Q_OBJECT
67 
68 private:
69 
70  struct Q_DECL_HIDDEN Args
71  {
72  explicit Args()
73  : start (0),
74  stop (0),
75  thold (nullptr),
76  lpass (nullptr),
77  hpass (nullptr),
78  stdev (nullptr),
79  samples (nullptr),
80  fimg (nullptr),
81  threshold (0.0),
82  softness (0.0)
83  {
84  }
85 
86  uint start;
87  uint stop;
88  float* thold;
89  uint* lpass;
90  uint* hpass;
91  double* stdev;
92  uint* samples;
93  float** fimg;
94  float threshold;
95  double softness;
96  };
97 
98 public:
99 
100  explicit NRFilter(QObject* const parent = nullptr);
101  NRFilter(DImg* const orgImage, QObject* const parent, const NRContainer& settings);
102  ~NRFilter() override;
103 
104  void readParameters(const FilterAction& action) override;
105 
106  FilterAction filterAction() override;
107  QString filterIdentifier() const override;
108 
109  static QString FilterIdentifier();
110  static QString DisplayableName();
111  static QList<int> SupportedVersions();
112  static int CurrentVersion();
113 
114  static void srgb2ycbcr(float** const fimg, int size);
115 
116 private:
117 
118  void filterImage() override;
119 
120  void waveletDenoise(float* fimg[3], unsigned int width, unsigned int height,
121  float threshold, double softness);
122  inline void hatTransform(float* const temp, float* const base, int st, int size, int sc);
123 
124  void ycbcr2srgb(float** const fimg, int size);
125 
126  void calculteStdevMultithreaded(const Args& prm);
127  void thresholdingMultithreaded(const Args& prm);
128 
129 private:
130 
131  class Private;
132  Private* const d;
133 };
134 
135 } // namespace Digikam
136 
137 #endif // DIGIKAM_NR_FILTER_H */
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: nrfilter.h:43
Definition: nrfilter.h:65
Definition: datefolderview.cpp:43
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition: dbengineparameters.cpp:863