|
| FilterEngine () |
| the default constructor More...
|
|
| FilterEngine (const Ptr< BaseFilter > &_filter2D, const Ptr< BaseRowFilter > &_rowFilter, const Ptr< BaseColumnFilter > &_columnFilter, int srcType, int dstType, int bufType, int _rowBorderType=BORDER_REPLICATE, int _columnBorderType=-1, const Scalar &_borderValue=Scalar()) |
| the full constructor. Either _filter2D or both _rowFilter and _columnFilter must be non-empty. More...
|
|
virtual | ~FilterEngine () |
| the destructor More...
|
|
void | init (const Ptr< BaseFilter > &_filter2D, const Ptr< BaseRowFilter > &_rowFilter, const Ptr< BaseColumnFilter > &_columnFilter, int srcType, int dstType, int bufType, int _rowBorderType=BORDER_REPLICATE, int _columnBorderType=-1, const Scalar &_borderValue=Scalar()) |
| reinitializes the engine. The previously assigned filters are released. More...
|
|
virtual int | start (Size wholeSize, Rect roi, int maxBufRows=-1) |
| starts filtering of the specified ROI of an image of size wholeSize. More...
|
|
virtual int | start (const Mat &src, const Rect &srcRoi=Rect(0, 0,-1,-1), bool isolated=false, int maxBufRows=-1) |
| starts filtering of the specified ROI of the specified image. More...
|
|
virtual int | proceed (const uchar *src, int srcStep, int srcCount, uchar *dst, int dstStep) |
| processes the next srcCount rows of the image. More...
|
|
virtual void | apply (const Mat &src, Mat &dst, const Rect &srcRoi=Rect(0, 0,-1,-1), Point dstOfs=Point(0, 0), bool isolated=false) |
| applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered. More...
|
|
bool | isSeparable () const |
| returns true if the filter is separable More...
|
|
int | remainingInputRows () const |
| returns the number More...
|
|
int | remainingOutputRows () const |
|
The Main Class for Image Filtering.
The class can be used to apply an arbitrary filtering operation to an image. It contains all the necessary intermediate buffers, it computes extrapolated values of the "virtual" pixels outside of the image etc. Pointers to the initialized cv::FilterEngine instances are returned by various OpenCV functions, such as cv::createSeparableLinearFilter(), cv::createLinearFilter(), cv::createGaussianFilter(), cv::createDerivFilter(), cv::createBoxFilter() and cv::createMorphologyFilter().
Using the class you can process large images by parts and build complex pipelines that include filtering as some of the stages. If all you need is to apply some pre-defined filtering operation, you may use cv::filter2D(), cv::erode(), cv::dilate() etc. functions that create FilterEngine internally.
Here is the example on how to use the class to implement Laplacian operator, which is the sum of second-order derivatives. More complex variant for different types is implemented in cv::Laplacian().
void laplace_f(
const Mat& src, Mat&
dst)
{
dst.create(src.size(), src.type());
Mat kd, ks;
getSobelKernels( kd, ks, 2, 0,
ksize,
false, ktype );
dst.type(), kd, ks,
Point(-1,-1), 0, borderType, borderType,
Scalar() );
dst.type(), ks, kd,
Point(-1,-1), 0, borderType, borderType,
Scalar() );
int y = Fxx->start(src), dsty = 0, dy = 0;
Fyy->start(src);
const uchar* sptr = src.data + y*src.step;
Mat Ixx( DELTA + kd.rows - 1, src.cols, dst.type() );
Mat Iyy( DELTA + kd.rows - 1, src.cols, dst.type() );
for( ; dsty < dst.rows; sptr += DELTA*src.step, dsty += dy )
{
Fxx->proceed( sptr, (int)src.step, DELTA, Ixx.data, (int)Ixx.step );
dy = Fyy->proceed( sptr, (int)src.step, DELTA, d2y.data, (int)Iyy.step );
if( dy > 0 )
{
Mat dstripe = dst.rowRange(dsty, dsty + dy);
add(Ixx.rowRange(0, dy), Iyy.rowRange(0, dy), dstripe);
}
}
}