Krita Source Code Documentation
Loading...
Searching...
No Matches
convolutionfilters.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 *
4 * SPDX-FileCopyrightText: 2004 Cyrille Berger <cberger@cberger.net>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
10
11#include <stdlib.h>
12
13#include <klocalizedstring.h>
14
15#include <kpluginfactory.h>
16
19
22#include <kis_selection.h>
23#include <kis_paint_device.h>
25
26#include <Eigen/Core>
27
28K_PLUGIN_FACTORY_WITH_JSON(KritaConvolutionFiltersFactory, "kritaconvolutionfilters.json", registerPlugin<KritaConvolutionFilters>();)
29
30KritaConvolutionFilters::KritaConvolutionFilters(QObject *parent, const QVariantList &)
31 : QObject(parent)
32{
34 manager->add(new KisSharpenFilter());
35 manager->add(new KisMeanRemovalFilter());
36 manager->add(new KisEmbossLaplascianFilter());
37 manager->add(new KisEmbossInAllDirectionsFilter());
39 manager->add(new KisEmbossVerticalFilter());
40 manager->add(new KisEmbossHorizontalFilter());
41}
42
46
48 : KisConvolutionFilter(id(), FiltersCategoryEnhanceId, i18n("&Sharpen"))
49{
52
53 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
54 kernelMatrix << 0, -2, 0,
55 -2, 11, -2,
56 0, -2, 0;
57
58 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0, 3);
59}
60
62 : KisConvolutionFilter(id(), FiltersCategoryEnhanceId, i18n("&Mean Removal"))
63{
66
67 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
68 kernelMatrix << -1, -1, -1,
69 -1, 9, -1,
70 -1, -1, -1;
71
72 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0, 1);
73}
74
76 : KisConvolutionFilter(id(), FiltersCategoryEmbossId, i18n("Emboss (Laplacian)"))
77{
80
81 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
82 kernelMatrix << -1, 0, -1,
83 0, 4, 0,
84 -1, 0, -1;
85
86 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
87 setIgnoreAlpha(true);
88}
89
91 : KisConvolutionFilter(id(), FiltersCategoryEmbossId, i18n("Emboss in All Directions"))
92{
95
96 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
97 kernelMatrix << -1, -1, -1,
98 -1, 8, -1,
99 -1, -1, -1;
100
101 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
102 setIgnoreAlpha(true);
103}
104
106 : KisConvolutionFilter(id(), FiltersCategoryEmbossId, i18n("Emboss Horizontal && Vertical"))
107{
108 setSupportsPainting(false);
110
111 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
112 kernelMatrix << 0, -1, 0,
113 -1, 4, -1,
114 0, -1, 0;
115
116 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
117 setIgnoreAlpha(true);
118}
119
121 : KisConvolutionFilter(id(), FiltersCategoryEmbossId, i18n("Emboss Vertical Only"))
122{
123 setSupportsPainting(false);
125
126 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
127 kernelMatrix << 0, -1, 0,
128 0, 2, 0,
129 0, -1, 0;
130
131 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
132 setIgnoreAlpha(true);
133}
134
136 KisConvolutionFilter(id(), FiltersCategoryEmbossId, i18n("Emboss Horizontal Only"))
137{
138 setSupportsPainting(false);
140
141 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
142 kernelMatrix << 0, 0, 0,
143 -1, 2, -1,
144 0, 0, 0;
145
146 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
147 setIgnoreAlpha(true);
148}
149
151 : KisConvolutionFilter(id(), FiltersCategoryEdgeDetectionId, i18n("Top Edge Detection"))
152{
153 setSupportsPainting(false);
155
156 Eigen::Matrix<qreal, Eigen::Dynamic, Eigen::Dynamic> kernelMatrix(3, 3);
157 kernelMatrix << -1, 0, -1,
158 0, 4, 0,
159 -1, 0, -1;
160
161 m_matrix = KisConvolutionKernel::fromMatrix(kernelMatrix, 0.5, 1);
162 setIgnoreAlpha(true);
163}
164
165#include "convolutionfilters.moc"
KisConvolutionKernelSP m_matrix
void add(KisFilterSP item)
static KisFilterRegistry * instance()
KritaConvolutionFilters(QObject *parent, const QVariantList &)
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL
const KoID FiltersCategoryEdgeDetectionId("edge_filters", ki18nc("The category of edge detection filters. Noun.", "Edge Detection"))
const KoID FiltersCategoryEnhanceId("enhance_filters", ki18nc("The category of enhancement filters, like sharpen. Verb.", "Enhance"))
const KoID FiltersCategoryEmbossId("emboss_filters", ki18nc("The category of emboss filters. Verb.", "Emboss"))
void setShowConfigurationWidget(bool v)
void setSupportsPainting(bool v)
static KisConvolutionKernelSP fromMatrix(Eigen::Matrix< qreal, Eigen::Dynamic, Eigen::Dynamic > matrix, qreal offset, qreal factor)