digiKam
refocusfilter.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 : Refocus threaded image filter.
8  *
9  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009 by Matthias Welwarsky <matze at welwarsky dot de>
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_REFOCUS_FILTER_H
27 #define DIGIKAM_REFOCUS_FILTER_H
28 
29 // Local includes
30 
31 #include "digikam_export.h"
32 #include "dimgthreadedfilter.h"
33 #include "digikam_globals.h"
34 
35 namespace Digikam
36 {
37 
38 class DIGIKAM_EXPORT RefocusFilter : public DImgThreadedFilter
39 {
40  Q_OBJECT
41 
42 private:
43 
44  struct Q_DECL_HIDDEN Args
45  {
46  explicit Args()
47  : orgData(nullptr),
48  destData(nullptr),
49  width(0),
50  height(0),
51  sixteenBit(false),
52  matrix(nullptr),
53  mat_size(0)
54  {
55  }
56 
57  uchar* orgData;
58  uchar* destData;
59  int width;
60  int height;
61  bool sixteenBit;
62  double* matrix;
63  uint mat_size;
64  };
65 
66 public:
67 
68  explicit RefocusFilter(QObject* const parent = nullptr);
69  explicit RefocusFilter(DImg* const orgImage, QObject* const parent = nullptr, int matrixSize=5, double radius=0.9,
70  double gauss=0.0, double correlation=0.5, double noise=0.01);
71 
72  ~RefocusFilter() override;
73 
74  static int maxMatrixSize();
75 
76  static QString FilterIdentifier()
77  {
78  return QLatin1String("digikam:RefocusFilter");
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 refocusImage(uchar* const data, int width, int height, bool sixteenBit,
107  int matrixSize, double radius, double gauss,
108  double correlation, double noise);
109 
110  void convolveImage(const Args& prm);
111 
112  void convolveImageMultithreaded(uint start, uint stop, uint y1, const Args& prm);
113 
114 private:
115 
116  class Private;
117  Private* const d;
118 };
119 
120 } // namespace Digikam
121 
122 #endif // DIGIKAM_REFOCUS_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: refocusfilter.h:39
QString filterIdentifier() const override
Definition: refocusfilter.h:93
static QString FilterIdentifier()
Definition: refocusfilter.h:76
static int CurrentVersion()
Definition: refocusfilter.h:88
static QList< int > SupportedVersions()
Definition: refocusfilter.h:83
MetaEngineRotation matrix(MetaEngineRotation::TransformationAction action)
Definition: metaengine_rotation.cpp:81
Definition: datefolderview.cpp:43