矩阵的边界填充类型
Mat C =(Mat_<uchar>(3,3)<<1,2,3,4,5,6,7,8,9); uchar *data = NULL; for (int row = 0; row < C.rows; row++) { data = (uchar *)C.ptr<uchar>(row); cout << "["; for (int col = 0; col < C.cols; col++) { cout << (int)data[col] << " "; } cout << "]" << endl; } Mat D; copyMakeBorder(C, D, 2, 2, 2, 2, BORDER_REPLICATE); for (int row = 0; row < D.rows; row++) { data = (uchar *)D.ptr<uchar>(row); cout << "["; for (int col = 0; col < D.cols; col++) { cout << (int)data[col] << " "; } cout << "]" << endl; } cout << endl;