今天简单来看一下OpenCV中的边界填充
@param src Source image.
@param dst Destination image of the same type as src and the size Size(src.cols+left+right,
src.rows+top+bottom) .
@param top the top pixels
@param bottom the bottom pixels
@param left the left pixels
@param right Parameter specifying how many pixels in each direction from the source image rectangle
to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
to be built.
@param borderType Border type. See borderInterpolate for details.
@param value Border value if borderType==BORDER_CONSTANT .@sa borderInterpolate
*/
CV_EXPORTS_W void copyMakeBorder(InputArray src, OutputArray dst,int top, int bottom, int left, int right,int borderType, const Scalar& value = Scalar() );
这里的核心就是理解borderType,具体就是
enum BorderTypes {BORDER_CONSTANT = 0, //!< `iiiiii|abcdefgh|iiiiiii` with some specified `i`BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh`BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101BORDER_ISOLATED = 16 //!< do not look outside of ROI
};
具体的理解:
其实不用记,实验一下就了解
OpenCV 4 功能 - 边界填充
发现两个问题:
- 图像宽度不为4的倍数时,画出会有错位现象
- 选择的颜色,B与R通道反了
这些问题,OpenCV肯定是不会改的,那就自己处理一下。