digiKam
Loading...
Searching...
No Matches
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 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19// Qt includes
20
21#include <QMetaType>
22#include <QDebug>
23
24// Local includes
25
26#include "digikam_export.h"
27#include "dimgthreadedfilter.h"
28
29namespace Digikam
30{
31
32class DIGIKAM_EXPORT NRContainer
33{
34
35public:
36
37 NRContainer() = default;
38 ~NRContainer() = default;
39
40public:
41
45 double thresholds[3] = { 1.2 };
46 double softness[3] = { 0.9 };
47};
48
50DIGIKAM_EXPORT QDebug operator<<(QDebug dbg, const NRContainer& inf);
51
52// --------------------------------------------------------------------------
53
54class DIGIKAM_EXPORT NRFilter : public DImgThreadedFilter
55{
56 Q_OBJECT
57
58private:
59
60 class Q_DECL_HIDDEN Args
61 {
62 public:
63
64 Args() = default;
65
66 uint start = 0;
67 uint stop = 0;
68 float* thold = nullptr;
69 uint* lpass = nullptr;
70 uint* hpass = nullptr;
71 double* stdev = nullptr;
72 uint* samples = nullptr;
73 float** fimg = nullptr;
74 float threshold = 0.0F;
75 double softness = 0.0;
76 };
77
78public:
79
80 explicit NRFilter(QObject* const parent = nullptr);
81 NRFilter(DImg* const orgImage, QObject* const parent, const NRContainer& settings);
82 ~NRFilter() override;
83
84 void readParameters(const FilterAction& action) override;
85
86 FilterAction filterAction() override;
87 QString filterIdentifier() const override;
88
89 static QString FilterIdentifier();
90 static QString DisplayableName();
91 static QList<int> SupportedVersions();
92 static int CurrentVersion();
93
94 static void srgb2ycbcr(float** const fimg, uint size);
95
96private:
97
98 void filterImage() override;
99
100 void waveletDenoise(float* fimg[3], unsigned int width, unsigned int height,
101 float threshold, double softness);
102 inline void hatTransform(float* const temp, float* const base, int st, int size, int sc);
103
104 void ycbcr2srgb(float** const fimg, uint size);
105
106 void calculteStdevMultithreaded(const Args& prm);
107 void thresholdingMultithreaded(const Args& prm);
108
109private:
110
111 class Private;
112 Private* const d = nullptr;
113};
114
115} // namespace Digikam
Definition dimgthreadedfilter.h:31
Definition dimg.h:52
Definition filteraction.h:33
Definition nrfilter.h:33
Definition nrfilter.h:55
Definition datefolderview.cpp:34
QDebug operator<<(QDebug dbg, const DbEngineParameters &p)
Definition dbengineparameters.cpp:930