digiKam
greycstorationfilter.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 : 2007-12-03
7  * Description : Greycstoration interface.
8  *
9  * Copyright (C) 2007-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_GREY_CSTORATION_FILTER_H
26 #define DIGIKAM_GREY_CSTORATION_FILTER_H
27 
28 // Qt includes
29 
30 #include <QImage>
31 
32 // Local includes
33 
34 #include "dimg.h"
35 #include "dimgthreadedfilter.h"
36 #include "digikam_export.h"
37 
38 class QObject;
39 
40 namespace Digikam
41 {
42 
43 class DIGIKAM_EXPORT GreycstorationContainer
44 {
45 
46 public:
47 
49  {
50  NearestNeighbor = 0,
52  RungeKutta
53  };
54 
55 public:
56 
58  {
59  setRestorationDefaultSettings();
60  };
61 
63  {
64  };
65 
67  {
68  fastApprox = true;
69 
70  tile = 256;
71  btile = 4;
72 
73  nbIter = 1;
74  interp = NearestNeighbor;
75 
76  amplitude = 60.0;
77  sharpness = 0.7F;
78  anisotropy = 0.3F;
79  alpha = 0.6F;
80  sigma = 1.1F;
81  gaussPrec = 2.0;
82  dl = 0.8F;
83  da = 30.0;
84  };
85 
87  {
88  fastApprox = true;
89 
90  tile = 256;
91  btile = 4;
92 
93  nbIter = 30;
94  interp = NearestNeighbor;
95 
96  amplitude = 20.0;
97  sharpness = 0.3F;
98  anisotropy = 1.0;
99  alpha = 0.8F;
100  sigma = 2.0;
101  gaussPrec = 2.0;
102  dl = 0.8F;
103  da = 30.0;
104  };
105 
107  {
108  fastApprox = true;
109 
110  tile = 256;
111  btile = 4;
112 
113  nbIter = 3;
114  interp = NearestNeighbor;
115 
116  amplitude = 20.0;
117  sharpness = 0.2F;
118  anisotropy = 0.9F;
119  alpha = 0.1F;
120  sigma = 1.5;
121  gaussPrec = 2.0;
122  dl = 0.8F;
123  da = 30.0;
124  };
125 
126 public:
127 
129 
130  int tile;
131  int btile;
132 
133  uint nbIter;
134  uint interp;
135 
136  float amplitude;
137  float sharpness;
138  float anisotropy;
139  float alpha;
140  float sigma;
141  float gaussPrec;
142  float dl;
143  float da;
144 };
145 
146 // --------------------------------------------------------------------------
147 
148 class DIGIKAM_EXPORT GreycstorationFilter : public DImgThreadedFilter
149 {
150  Q_OBJECT
151 
152 public:
153 
154  enum MODE
155  {
156  Restore = 0,
159  SimpleResize
160  };
161 
162 public:
163 
169  explicit GreycstorationFilter(QObject* const parent = nullptr);
170 
174  GreycstorationFilter(DImg* const orgImage,
175  const GreycstorationContainer& settings,
176  int mode = Restore,
177  int newWidth = 0, int newHeight = 0,
178  const QImage& inPaintingMask = QImage(),
179  QObject* const parent = nullptr);
180 
181  ~GreycstorationFilter() override;
182 
183  void setMode(int mode, int newWidth = 0, int newHeight = 0);
184  void setSettings(const GreycstorationContainer& settings);
185  void setInPaintingMask(const QImage& inPaintingMask);
186 
187  void setup();
188 
189  void cancelFilter() override;
190 
191  static QString cimgVersionString();
192 
193  static QString FilterIdentifier()
194  {
195  return QLatin1String("digikam:GreycstorationFilter");
196  }
197 
198  static QString DisplayableName();
199 
201  {
202  return QList<int>() << 1;
203  }
204 
205  static int CurrentVersion()
206  {
207  return 1;
208  }
209 
210  QString filterIdentifier() const override
211  {
212  return FilterIdentifier();
213  }
214 
215  FilterAction filterAction() override;
216  void readParameters(const FilterAction& action) override;
217 
218 private:
219 
220  void computeChildrenThreads();
221  void restoration();
222  void inpainting();
223  void resize();
224  void simpleResize();
225  void iterationLoop(uint iter);
226 
227  void initFilter() override;
228  void filterImage() override;
229 
230 private:
231 
232  class Private;
233  Private* const d;
234 };
235 
236 } // namespace Digikam
237 
238 #endif // DIGIKAM_GREY_CSTORATION_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: greycstorationfilter.h:44
float amplitude
Definition: greycstorationfilter.h:136
float sharpness
Definition: greycstorationfilter.h:137
uint nbIter
Definition: greycstorationfilter.h:133
float anisotropy
Definition: greycstorationfilter.h:138
float da
Definition: greycstorationfilter.h:143
void setRestorationDefaultSettings()
Definition: greycstorationfilter.h:66
uint interp
Definition: greycstorationfilter.h:134
~GreycstorationContainer()
Definition: greycstorationfilter.h:62
void setResizeDefaultSettings()
Definition: greycstorationfilter.h:106
void setInpaintingDefaultSettings()
Definition: greycstorationfilter.h:86
float sigma
Definition: greycstorationfilter.h:140
float alpha
Definition: greycstorationfilter.h:139
bool fastApprox
Definition: greycstorationfilter.h:124
float gaussPrec
Definition: greycstorationfilter.h:141
float dl
Definition: greycstorationfilter.h:142
int tile
Definition: greycstorationfilter.h:130
GreycstorationContainer()
Definition: greycstorationfilter.h:57
int btile
Definition: greycstorationfilter.h:131
INTERPOLATION
Definition: greycstorationfilter.h:49
@ Linear
Definition: greycstorationfilter.h:51
Definition: greycstorationfilter.h:149
static int CurrentVersion()
Definition: greycstorationfilter.h:205
QString filterIdentifier() const override
Definition: greycstorationfilter.h:210
static QList< int > SupportedVersions()
Definition: greycstorationfilter.h:200
MODE
Definition: greycstorationfilter.h:155
@ Resize
Definition: greycstorationfilter.h:158
@ InPainting
Definition: greycstorationfilter.h:157
static QString FilterIdentifier()
Definition: greycstorationfilter.h:193
Definition: datefolderview.cpp:43