26 #include <fvfilters/threshold.h> 28 #include <core/exception.h> 34 #elif defined(HAVE_OPENCV) 35 # if CV_MAJOR_VERSION < 2 || (CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION < 4) 36 # include <opencv/cv.h> 38 # include <opencv/cv.hpp> 40 # error "Neither IPP nor OpenCV available" 63 unsigned char max,
unsigned char max_replace)
64 :
Filter(
"FilterThreshold")
68 this->min_replace = min_replace;
69 this->max_replace = max_replace;
70 #if defined(HAVE_OPENCV) 71 if (min_replace != 0) {
72 throw fawkes::Exception(
"OpenCV-based threshold filter only allows min_replace=0");
87 unsigned char max,
unsigned char max_replace)
91 this->min_replace = min_replace;
92 this->max_replace = max_replace;
109 size, max, max_replace );
110 if ( status == ippStsNoErr ) {
111 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,
112 size, min, min_replace );
118 size, max, max_replace );
120 if ( status == ippStsNoErr ) {
121 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,
123 size, min, min_replace );
127 if ( status != ippStsNoErr ) {
131 #elif defined(HAVE_OPENCV) 140 src_roi[0]->line_step);
148 cv::threshold(srcm, dstm, max, max_replace, cv::THRESH_BINARY);
149 cv::threshold(srcm, dstm, min, 0, cv::THRESH_TOZERO);
fawkes::upoint_t start
ROI start.
unsigned int y
y coordinate
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.
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.