digiKam
hotpixelfixer.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-03-27
7  * Description : Threaded image filter to fix hot pixels
8  *
9  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2005-2006 by Unai Garro <ugarro at users dot sourceforge dot net>
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_HOT_PIXEL_FIXER_H
26 #define DIGIKAM_HOT_PIXEL_FIXER_H
27 
28 // Qt includes
29 
30 #include <QList>
31 #include <QImage>
32 #include <QObject>
33 #include <QRect>
34 #include <QString>
35 
36 // Local includes
37 
38 #include "digikam_export.h"
39 #include "dimgthreadedfilter.h"
40 #include "hotpixelprops.h"
41 #include "hotpixelsweights.h"
42 #include "hotpixelcontainer.h"
43 
44 using namespace Digikam;
45 
46 namespace Digikam
47 {
48 
49 class DIGIKAM_EXPORT HotPixelFixer : public DImgThreadedFilter
50 {
51  Q_OBJECT
52 
53 public:
54 
55  explicit HotPixelFixer(QObject* const parent = nullptr);
56  explicit HotPixelFixer(DImg* const orgImage,
57  QObject* const parent,
58  const HotPixelContainer& settings);
59  ~HotPixelFixer() override;
60 
61  static QString FilterIdentifier()
62  {
63  return QLatin1String("digikam:HotPixelFilter");
64  }
65 
66  static QString DisplayableName();
67 
69  {
70  return QList<int>() << 1;
71  }
72 
73  static int CurrentVersion()
74  {
75  return 1;
76  }
77 
78  void readParameters(const FilterAction& action) override;
79 
80  QString filterIdentifier() const override
81  {
82  return FilterIdentifier();
83  }
84 
85  Digikam::FilterAction filterAction() override;
86 
87 private:
88 
89  void filterImage() override;
90 
91  void interpolate(DImg& img,
92  HotPixelProps& hp,
93  int method);
94 
95  void weightPixels(DImg& img,
96  HotPixelProps& px,
97  int method,
99  int maxComponent);
100 
101  inline bool validPoint(DImg& img, const QPoint& p)
102  {
103  return (
104  (p.x() >= 0) &&
105  (p.y() >= 0) &&
106  (p.x() < (long) img.width()) &&
107  (p.y() < (long) img.height())
108  );
109  };
110 
111 
112 private:
113 
114  QList<HotPixelsWeights> m_weightList;
115 
116  HotPixelContainer m_settings;
117 };
118 
119 } // namespace Digikam
120 
121 #endif // DIGIKAM_HOT_PIXEL_FIXER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
unsigned int height
Definition: dimg_p.h:152
unsigned int width
Definition: dimg_p.h:151
Definition: filteraction.h:43
Definition: hotpixelcontainer.h:44
Direction
Definition: hotpixelcontainer.h:57
Definition: hotpixelfixer.h:50
static int CurrentVersion()
Definition: hotpixelfixer.h:73
static QList< int > SupportedVersions()
Definition: hotpixelfixer.h:68
QString filterIdentifier() const override
Definition: hotpixelfixer.h:80
static QString FilterIdentifier()
Definition: hotpixelfixer.h:61
Definition: hotpixelprops.h:41
Definition: datefolderview.cpp:43