Overload List
Overload 1: TMtx *Filter2D(TMtx *Src, TMtx *Kernel, const TMtxRect &SrcRect, const TMtxRect &DstRect, const TMtxPoint &KernelAnchor, TVecInt *Buffer = null) const;
Applies 2D filtering
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TMtx * | |
| 2 | Kernel | TMtx * | |
| 3 | SrcRect | const TMtxRect & | |
| 4 | DstRect | const TMtxRect & | |
| 5 | KernelAnchor | const TMtxPoint & | |
| 6 | Buffer = null | TVecInt * |
Computes the dot-product between the kernel matrix and underlaying source matrix elements for each possible position of the kernel and stores the result in to the calling object. Typically the kernel is much smaller than the source matrix. The operation is equivalent to the 2D Convolution and is used also for image resampling, image blurring etc..
SrcRect must meet the following condtitions:
SrcRect.Width <= (Src.Cols - Kernel.Cols) SrcRect.Height <= (Src.Rows - Kernel.Rows)
KernelAnchor defines the value to be written in the destination matrix relative to the corresponding position of the Kernel in the Src matrix. This can be for example center element (Kernel.Rows div 2, Kernel.Cols div 2), top left (0,0), bottom right (Kernel.Rows-1, Kernel.Cols-1) element etc... The X and Y coordinates may not exceed Kernel row or column count.
The kernel can be square or not. Symmetric or not. The only requirement is that it is rectangular.
It is the users responsability to select such combination of SrcRect, Kernel size and KernelAnchor to get desired border value processing. If the Kernel is 3x3 in size, then it would make sense that SrcRect leaves out 2 rows above and below and also 2 columns left and right in the Src matrix. These regions then need to be initialized to some value for example 0 for black color or use the value of the closest border element.
The DstRect defines the area to be overwritten in the destination matrix. The width and height parameters of DstRect and SrcRect need to match. The Size of the destination matrix needs to be big enough to allow DstRect position and dimensions.
Overload 2: TMtx *Filter2D(TMtx *Src, TMtx *Kernel, const TMtxRect &SrcRect, const TMtxPoint &KernelAnchor, TVecInt *Buffer = null) const;
Applies 2D filtering.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TMtx * | |
| 2 | Kernel | TMtx * | |
| 3 | SrcRect | const TMtxRect & | |
| 4 | KernelAnchor | const TMtxPoint & | |
| 5 | Buffer = null | TVecInt * |
The result is stored in to the calling object. The size of the calling object is set to match SrcRect dimensions.
Important: The allocated size of the destination will never be overwritten, but the value of samples on the edge of the Dst matrix could be computed from elements outside of the Src thus making them appear to be random, because uninitialized memory was being referenced, if the parameters are not set carefully.
Overload 3: TMtx *Filter2D(TMtx *Src, TMtx *Kernel, TVecInt *Buffer = null) const;
Applies 2D filtering.
The function will assume that Src has a border which is (Kernel.Cols div 2+1) wide on left and right and border which is (Kernel.Rows div 2 + 1) high on top and bottom. Kernel will be applied with its center element as the anchor. The filtered result will be stored in to the calling object without the extra borders. The size of the calling object is set automatically.
It is the users responsability to initialize the border elements in the Src.