26 #include <fvfilters/threshold.h> 28 #include <core/exception.h> 34 #elif defined(HAVE_OPENCV) 36 # include <opencv2/imgproc.hpp> 38 # error "Neither IPP nor OpenCV available" 61 unsigned char max,
unsigned char max_replace)
62 :
Filter(
"FilterThreshold")
66 this->min_replace = min_replace;
67 this->max_replace = max_replace;
68 #if defined(HAVE_OPENCV) 69 if (min_replace != 0) {
70 throw fawkes::Exception(
"OpenCV-based threshold filter only allows min_replace=0");
85 unsigned char max,
unsigned char max_replace)
89 this->min_replace = min_replace;
90 this->max_replace = max_replace;
107 size, max, max_replace );
108 if ( status == ippStsNoErr ) {
109 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,
110 size, min, min_replace );
116 size, max, max_replace );
118 if ( status == ippStsNoErr ) {
119 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,
121 size, min, min_replace );
125 if ( status != ippStsNoErr ) {
129 #elif defined(HAVE_OPENCV) 138 src_roi[0]->line_step);
146 cv::threshold(srcm, dstm, max, max_replace, cv::THRESH_BINARY);
147 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.
FilterThreshold(unsigned char min=128, unsigned char min_replace=0, unsigned char max=127, unsigned char max_replace=255)
Constructor.
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.