-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathThreshold.cpp
42 lines (39 loc) · 950 Bytes
/
Threshold.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Threshold.h"
namespace cvImagePipeline {
namespace Filter {
using namespace std;
using namespace cv;
IMPLEMENT_CVFILTER(Threshold);
Threshold::Threshold()
:
thresh("thresh", 0.0),
maxval("maxval", 0.0),
type("type", ThreshBinary),
otsu("otsu", false)
{
defParam(thresh);
defParam(maxval);
defParam(type);
defParam(otsu);
updateThreashType();
}
Threshold::~Threshold() { }
void Threshold::execute() {
const Mat& input_image = getInputMat();
if(input_image.empty()) {
return;
}
Mat& output = refOutputMat();
cv::threshold(input_image, output, thresh, maxval, thresh_type);
}
void Threshold::onPropertyChange(Property& property) {
const string& name = property.getName();
if (name == "type" || name == "otsu") {
updateThreashType();
}
}
void Threshold::updateThreashType() {
thresh_type = ((type & CV_THRESH_MASK) | (otsu ? CV_THRESH_OTSU : 0));
}
}
}