get_sampling_window_offset
Description
Get offset array for sampling window, via center point
Syntax
int get_sampling_window_offset( int * pOffset, int * pXOffSet, int * pYOffSet, int nCols, int nWinSizeX, int nWinSizeY, int nSampling = FILTERSHAPE_SQUARE )
Parameters
- pOffset
- [modify] array offset, the input size is nWinsizeX*nWinSizeY, output size is the size of real offset data.
- NOTE: the col size is the col size of matrix need be filtered instead of window.
- pXOffSet
- [output] array offset of x axle
- pYOffSet
- [output] array offset of y axle
- nCols
- [input] matrix col size need to be filtered
- nWinSizeX
- [input] window x axle size, must be odd(1, 3, 5,...)
- nWinSizeY
- [input] window y axle size, must be odd(1, 3, 5,...)
- nSampling
- [input] can be FILTERSHAPE_SQUARE, FILTERSHAPE_CIRCULAR, FILTERSHAPE_STRAIGHT_CROSS('+'), FILTERSHAPE_DIAGONAL_CROSS('X')
- when shape is FILTERSHAPE_CIRCULAR or FILTERSHAPE_DIAGONAL_CROSS nWinSizeX must equal nWinSizeY
Return
size of offset array, return -1 when there is a error.
Examples
EX1
void get_sampling_window_offset_ex1()
{
int nWinSizeX = 3;
int nWinSizeY = 3;
int nSampling = FILTERSHAPE_STRAIGHT_CROSS;
int nCol = 10;
//0 1 0
//1 1 1
//0 1 0
vector<int> vnOffset;
vector<int> vnXOffSet;
vector<int> vnYOffSet;
vnOffset.SetSize(nCol);
vnXOffSet.SetSize(nWinSizeX);
vnYOffSet.SetSize(nWinSizeY);
int nOffset = get_sampling_window_offset(vnOffset, vnXOffSet, vnYOffSet, nCol, nWinSizeX, nWinSizeY, nSampling);
//return 5(size of real data in pOffset)
//int vnOffset = { -10 0 10 -1 1 } // ncol = 10
//int vnXOffSet = { 0 -1 0 -1 0 }
//int vnYOffSet = { -1 0 0 0 1 }
}
Remark
See Also
header to Include
origin.h
Reference
|