26 #include <fvfilters/threshold.h>
28 #include <core/exception.h>
34 #elif defined(HAVE_OPENCV)
37 # error "Neither IPP nor OpenCV available"
40 namespace firevision {
59 FilterThreshold::FilterThreshold(
unsigned char min,
unsigned char min_replace,
60 unsigned char max,
unsigned char max_replace)
61 :
Filter(
"FilterThreshold")
65 this->min_replace = min_replace;
66 this->max_replace = max_replace;
67 #if defined(HAVE_OPENCV)
68 if (min_replace != 0) {
69 throw fawkes::Exception(
"OpenCV-based threshold filter only allows min_replace=0");
84 unsigned char max,
unsigned char max_replace)
88 this->min_replace = min_replace;
89 this->max_replace = max_replace;
106 size, max, max_replace );
107 if ( status == ippStsNoErr ) {
108 status = ippiThreshold_LTVal_8u_C1IR(
src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step), src_roi[0]->line_step,
109 size, min, min_replace );
115 size, max, max_replace );
117 if ( status == ippStsNoErr ) {
118 status = ippiThreshold_LTVal_8u_C1R(
src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step), src_roi[0]->line_step,
120 size, min, min_replace );
124 if ( status != ippStsNoErr ) {
128 #elif defined(HAVE_OPENCV)
137 src_roi[0]->line_step);
145 cv::threshold(srcm, dstm, max, max_replace, cv::THRESH_BINARY);
146 cv::threshold(srcm, dstm, min, 0, cv::THRESH_TOZERO);
fawkes::point_t start
ROI start.
unsigned int x
x coordinate
unsigned int width
ROI width.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Base class for exceptions in Fawkes.
unsigned int y
y coordinate
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
unsigned int height
ROI height.
virtual void apply()
Apply the filter.
unsigned int line_step
line step
unsigned char * dst
Destination buffer.
unsigned int pixel_step
pixel step
void set_thresholds(unsigned char min, unsigned char min_replace, unsigned char max, unsigned char max_replace)
Set new thresholds.
ROI * dst_roi
Destination ROI.