digiKam
sharpenfilter.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-17-07
7  * Description : A Sharpen threaded image filter.
8  *
9  * Copyright (C) 2005-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_SHARPEN_FILTER_H
26 #define DIGIKAM_SHARPEN_FILTER_H
27 
28 // Local includes
29 
30 #include "digikam_export.h"
31 #include "dimgthreadedfilter.h"
32 #include "digikam_globals.h"
33 
34 namespace Digikam
35 {
36 
37 class DIGIKAM_EXPORT SharpenFilter : public DImgThreadedFilter
38 {
39  Q_OBJECT
40 
41 private:
42 
43  struct Q_DECL_HIDDEN Args
44  {
45  explicit Args()
46  : start(0),
47  stop(0),
48  y(0),
49  kernelWidth(0),
50  normal_kernel(nullptr),
51  halfKernelWidth(0)
52  {
53  }
54 
55  uint start;
56  uint stop;
57  uint y;
58  long kernelWidth;
59  double* normal_kernel;
60  long halfKernelWidth;
61  };
62 
63 public:
64 
65  explicit SharpenFilter(QObject* const parent = nullptr);
66  explicit SharpenFilter(DImg* const orgImage, QObject* const parent = nullptr, double radius=0.0, double sigma=1.0);
67 
71  SharpenFilter(DImgThreadedFilter* const parentFilter, const DImg& orgImage, const DImg& destImage,
72  int progressBegin=0, int progressEnd=100, double radius=0.0, double sigma=1.0);
73 
74  ~SharpenFilter() override;
75 
76  static QString FilterIdentifier()
77  {
78  return QLatin1String("digikam:SharpenFilter");
79  }
80 
81  static QString DisplayableName();
82 
84  {
85  return QList<int>() << 1;
86  }
87 
88  static int CurrentVersion()
89  {
90  return 1;
91  }
92 
93  QString filterIdentifier() const override
94  {
95  return FilterIdentifier();
96  }
97 
98  FilterAction filterAction() override;
99  void readParameters(const FilterAction& action) override;
100 
101 
102 private:
103 
104  void filterImage() override;
105 
106  void sharpenImage(double radius, double sigma);
107 
108  bool convolveImage(const unsigned int order, const double* const kernel);
109 
110  void convolveImageMultithreaded(const Args& prm);
111 
112  int getOptimalKernelWidth(double radius, double sigma);
113 
114 private:
115 
116  double m_radius;
117  double m_sigma;
118 };
119 
120 } // namespace Digikam
121 
122 #endif // DIGIKAM_SHARPEN_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: sharpenfilter.h:38
QString filterIdentifier() const override
Definition: sharpenfilter.h:93
static QString FilterIdentifier()
Definition: sharpenfilter.h:76
static int CurrentVersion()
Definition: sharpenfilter.h:88
static QList< int > SupportedVersions()
Definition: sharpenfilter.h:83
Definition: datefolderview.cpp:43