只用来记录学习笔记
先定义:
int top = (int)(0.05*src.rows);
int bottom = (int)(0.05*src.rows);
int left = (int)(0.05*src.rows);
int right = (int)(0.05*src.rows);
RNG rng(12345);
Scalar color = Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255)); //随机生成一种颜色
- BORDER_DEFAULT 用等宽边缘像素扩充:
//BORDER_DEFAULT
copyMakeBorder(src, dst1, top, bottom, left, right, BORDER_DEFAULT, color);
imshow("BORDER_DEFAULT", dst1);
2. BORDER_REPLICATE 用边缘的一个像素扩充:
//BORDER_REPLICATE
copyMakeBorder(src, dst2, top, bottom, left, right, BORDER_REPLICATE, color);
imshow("BORDER_REPLICATE", dst2);
- BORDER_WRAP 上方用下方像素扩充:
//BORDER_WRAP
copyMakeBorder(src, dst3, top, bottom, left, right, BORDER_WRAP, color);
imshow("BORDER_WRAP", dst3);
4. BORDER_CONSTANT 用特定的颜色填充:
//BORDER_CONSTANT
copyMakeBorder(src, dst4, top, bottom, left, right, BORDER_CONSTANT, color);//颜色随机
imshow("BORDER_CONSTANT", dst4);