Pad a matrix with selected way
BOOL Padding( matrixbase & mPadding, int nPadSize, int nPaddingOption = MFILTER_ZEROPADDINGWINDOW )
Returns TRUE on success or FALSE on failure.
EX1
void matrixbase_Padding_ex1() { matrix<double> mat1 = { {1, 2, 3, 4}, {2, 4, 6, 8}, {5, 10, 15, 20} }; MatrixPage MatPg1; MatPg1.Create("Origin"); MatrixLayer MatLy1 = MatPg1.Layers(0); Matrix Mat1(MatLy1); Mat1 = mat1; MatrixPage MatPg2; MatPg2.Create("Origin"); MatrixLayer MatLy2 = MatPg2.Layers(0); Matrix Mat2(MatLy2); int rc = Mat1.Padding( Mat2, 2 ); // default is MFILTER_ZEROPADDINGWINDOW if(!rc) printf("Error: Padding on a matrix failed. (Option:ZEROPADDINGWINDOW (default))\n"); else printf("Observe the padded matrix window %s from %s. (Option:ZEROPADDINGWINDOW (default))\n", Mat2.GetName(),Mat1.GetName()); MatrixPage MatPg3; MatPg3.Create("Origin"); MatrixLayer MatLy3 = MatPg3.Layers(0); Matrix Mat3(MatLy3); rc = Mat1.Padding( Mat3, 2, MFILTER_MAPPADDINGWINDOW ); if(!rc) printf("Error: Padding on a matrix failed. (Option:MAPPADDINGWINDOW)\n"); else printf("Observe the padded matrix window %s from %s. (Option:MAPPADDINGWINDOW)\n", Mat3.GetName(),Mat1.GetName()); MatrixPage MatPg4; MatPg4.Create("Origin"); MatrixLayer MatLy4 = MatPg4.Layers(0); Matrix Mat4(MatLy4); rc = Mat1.Padding( Mat4, 2, MFILTER_REPEATEDGEPADDINGWINDOW ); if(!rc) printf("Error: Padding on a matrix failed. (Option:REPEATEDGEPADDINGWINDOW)\n"); else printf("Observe the padded matrix window %s from %s. (Option:REPEATEDGEPADDINGWINDOW)\n", Mat4.GetName(),Mat1.GetName()); }
Pad a matrix with 0 or with adjacent cell values.
origin.h