opencv 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
cv::FilterEngine Class Reference

`#include <imgproc.hpp>`

## Public Member Functions
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.
| FilterEngine ()
| the default constructor
| 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.
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.
bool | isSeparable () const
| returns true if the filter is separable
virtual int | proceed (const uchar *src, int srcStep, int srcCount, uchar *dst, int dstStep)
| processes the next srcCount rows of the image.
int | remainingInputRows () const
| returns the number
int | remainingOutputRows () const
virtual int | start (Size wholeSize, Rect roi, int maxBufRows=-1)
| starts filtering of the specified ROI of an image of size wholeSize.
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.
virtual | ~FilterEngine ()
| the destructor

## Public Attributes
Point | anchor
int | borderElemSize
vector< int > | borderTab
int | bufStep
int | bufType
int | columnBorderType
Ptr< BaseColumnFilter > | columnFilter
vector< uchar > | constBorderRow
vector< uchar > | constBorderValue
int | dstType
int | dstY
int | dx1
int | dx2
int | endY
Ptr< BaseFilter > | filter2D
Size | ksize
int | maxWidth
vector< uchar > | ringBuf
Rect | roi
int | rowBorderType
int | rowCount
Ptr< BaseRowFilter > | rowFilter
vector< uchar * > | rows
vector< uchar > | srcRow
int | srcType
int | startY
int | startY0
Size | wholeSize

## Detailed Description

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)
{
CV_Assert( src.type() == CV_32F );
// make sure the destination array has the proper size and type
dst.create(src.size(), src.type());
// get the derivative and smooth kernels for d2I/dx2.
// for d2I/dy2 we could use the same kernels, just swapped
Mat kd, ks;
getSobelKernels( kd, ks, 2, 0, ksize, false, ktype );
// let's process 10 source rows at once
int DELTA = std::min(10, src.rows);
Ptr<FilterEngine> Fxx = createSeparableLinearFilter(src.type(),
dst.type(), kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() );
Ptr<FilterEngine> Fyy = createSeparableLinearFilter(src.type(),
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;
// allocate the buffers for the spatial image derivatives;
// the buffers need to have more than DELTA rows, because at the
// last iteration the output may take max(kd.rows-1,ks.rows-1)
// rows more than the input.
Mat Ixx( DELTA + kd.rows - 1, src.cols, dst.type() );
Mat Iyy( DELTA + kd.rows - 1, src.cols, dst.type() );
// inside the loop we always pass DELTA rows to the filter
// (note that the "proceed" method takes care of possibe overflow, since
// it was given the actual image height in the "start" method)
// on output we can get:
// * < DELTA rows (the initial buffer accumulation stage)
// * = DELTA rows (settled state in the middle)
// * > DELTA rows (then the input image is over, but we generate
// "virtual" rows using the border mode and filter them)
// this variable number of output rows is dy.
// dsty is the current output row.
// sptr is the pointer to the first input row in the portion to process
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);
}
}
}

## Constructor & Destructor Documentation

cv::FilterEngine::FilterEngine | ( |  | ) |

the default constructor

cv::FilterEngine::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.

virtual cv::FilterEngine::~FilterEngine | ( |  | ) |
| virtual

the destructor

## Member Function Documentation

virtual void cv::FilterEngine::apply | ( | const Mat & | src,
|  | Mat & | dst,
|  | const Rect & | srcRoi = `Rect(0, 0,-1,-1)`,
|  | Point | dstOfs = `Point(0, 0)`,
|  | bool | isolated = `false`
| ) |  |
| virtual

applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered.

void cv::FilterEngine::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.

bool cv::FilterEngine::isSeparable | ( |  | ) | const
| inline

returns true if the filter is separable

virtual int cv::FilterEngine::proceed | ( | const uchar * | src,
|  | int | srcStep,
|  | int | srcCount,
|  | uchar * | dst,
|  | int | dstStep
| ) |  |
| virtual

processes the next srcCount rows of the image.

int cv::FilterEngine::remainingInputRows | ( |  | ) | const

returns the number

int cv::FilterEngine::remainingOutputRows | ( |  | ) | const

virtual int cv::FilterEngine::start | ( | Size | wholeSize,
|  | Rect | roi,
|  | int | maxBufRows = `-1`
| ) |  |
| virtual

starts filtering of the specified ROI of an image of size wholeSize.

virtual int cv::FilterEngine::start | ( | const Mat & | src,
|  | const Rect & | srcRoi = `Rect(0, 0,-1,-1)`,
|  | bool | isolated = `false`,
|  | int | maxBufRows = `-1`
| ) |  |
| virtual

starts filtering of the specified ROI of the specified image.

## Member Data Documentation

Point cv::FilterEngine::anchor

int cv::FilterEngine::borderElemSize

vector<int> cv::FilterEngine::borderTab

int cv::FilterEngine::bufStep

int cv::FilterEngine::bufType

int cv::FilterEngine::columnBorderType

Ptr<BaseColumnFilter> cv::FilterEngine::columnFilter

vector<uchar> cv::FilterEngine::constBorderRow

vector<uchar> cv::FilterEngine::constBorderValue

int cv::FilterEngine::dstType

int cv::FilterEngine::dstY

int cv::FilterEngine::dx1

int cv::FilterEngine::dx2

int cv::FilterEngine::endY

Ptr<BaseFilter> cv::FilterEngine::filter2D

Size cv::FilterEngine::ksize

int cv::FilterEngine::maxWidth

vector<uchar> cv::FilterEngine::ringBuf

Rect cv::FilterEngine::roi

int cv::FilterEngine::rowBorderType

int cv::FilterEngine::rowCount

Ptr<BaseRowFilter> cv::FilterEngine::rowFilter

vector<uchar*> cv::FilterEngine::rows

vector<uchar> cv::FilterEngine::srcRow

int cv::FilterEngine::srcType

int cv::FilterEngine::startY

int cv::FilterEngine::startY0

Size cv::FilterEngine::wholeSize

The documentation for this class was generated from the following file:

- /usr/obj/OpenCV-2.2.0/OpenCV-2.2.0/modules/imgproc/include/opencv2/imgproc/imgproc.hpp