SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
sobelfilter.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include "slideio/transformer/transformationex.hpp"
6#include "slideio/base/slideio_enums.hpp"
7#include "slideio/transformer/transformationtype.hpp"
8
9namespace slideio
10{
11
12 class SLIDEIO_TRANSFORMER_EXPORTS SobelFilter : public TransformationEx
13 {
14 public:
15 SobelFilter(const SobelFilter& other)
16 : TransformationEx(other),
17 m_depth(other.m_depth),
18 m_dx(other.m_dx),
19 m_dy(other.m_dy),
20 m_ksize(other.m_ksize),
21 m_scale(other.m_scale),
22 m_delta(other.m_delta) {
23 }
24
25 SobelFilter(SobelFilter&& other) noexcept
26 : TransformationEx(std::move(other)),
27 m_depth(other.m_depth),
28 m_dx(other.m_dx),
29 m_dy(other.m_dy),
30 m_ksize(other.m_ksize),
31 m_scale(other.m_scale),
32 m_delta(other.m_delta) {
33 }
34
35 SobelFilter& operator=(const SobelFilter& other) {
36 if (this == &other)
37 return *this;
38 TransformationEx::operator =(other);
39 m_depth = other.m_depth;
40 m_dx = other.m_dx;
41 m_dy = other.m_dy;
42 m_ksize = other.m_ksize;
43 m_scale = other.m_scale;
44 m_delta = other.m_delta;
45 return *this;
46 }
47
48 SobelFilter& operator=(SobelFilter&& other) noexcept {
49 if (this == &other)
50 return *this;
51 TransformationEx::operator =(std::move(other));
52 m_depth = other.m_depth;
53 m_dx = other.m_dx;
54 m_dy = other.m_dy;
55 m_ksize = other.m_ksize;
56 m_scale = other.m_scale;
57 m_delta = other.m_delta;
58 return *this;
59 }
60
61 SobelFilter()
62 {
63 m_type = TransformationType::SobelFilter;
64 }
65
66 DataType getDepth() const
67 {
68 return m_depth;
69 }
70
71 void setDepth(const DataType& depth)
72 {
73 m_depth = depth;
74 }
75
76 int getDx() const
77 {
78 return m_dx;
79 }
80
81 void setDx(int dx)
82 {
83 m_dx = dx;
84 }
85
86 int getDy() const
87 {
88 return m_dy;
89 }
90
91 void setDy(int dy)
92 {
93 m_dy = dy;
94 }
95
96 int getKernelSize() const
97 {
98 return m_ksize;
99 }
100
101 void setKernelSize(int ksize)
102 {
103 m_ksize = ksize;
104 }
105
106 double getScale() const
107 {
108 return m_scale;
109 }
110
111 void setScale(double scale)
112 {
113 m_scale = scale;
114 }
115
116 double getDelta() const
117 {
118 return m_delta;
119 }
120
121 void setDelta(double delta)
122 {
123 m_delta = delta;
124 }
125
126 void applyTransformation(const cv::Mat& block, cv::OutputArray transformedBlock) const override;
127 int getInflationValue() const override;
128 std::vector<DataType> computeChannelDataTypes(const std::vector<DataType>& channels) const override;
129
130 private:
131 DataType m_depth = DataType::DT_Float32;
132 int m_dx = 1;
133 int m_dy = 1;
134 int m_ksize = 3;
135 double m_scale = 1.;
136 double m_delta = 0.;
137 };
138
139}
Definition: exceptions.hpp:15