opencv, copyMakeBorder image edge padding

In the OpenCV filtering algorithm, there are two very important basic tool functions, copyMakeBorder and borderInterpolate
copyMakeBorder
function prototype

void copyMakeBorder( const Mat& src, Mat& dst,
int top, int bottom, int left, int right,
int borderType, const Scalar& value=Scalar() );

The function
expands the edge of src, enlarges the image, and then automatically fills the image boundary with various extrapolation methods. This function actually calls the function cv::borderInterpolate. The most important function of this function is to process the boundary, such as mean filtering or In the median filter, use copyMakeBorder to slightly enlarge the original image, and then we can deal with the boundary situation

Parameter description:
src, dst: the original image and the target image
top, bottom, left, right respectively indicate the size of the expanded edge around the original image
borderType: the type of the expanded edge, which is the type of extrapolation, and the following methods are given in OpenCV

  • BORDER_REPLICATE
  • BORDER_REFLECT
  • BORDER_REFLECT_101
  • BORDER_WRAP
  • BORDER_CONSTANT

What do these ways mean?

OpenCV gives an explanation:

 Various border types, image boundaries are denoted with '|'
 * BORDER_REPLICATE:     aaaaaa|abcdefgh|hhhhhhh //复制法,也就是复制最边缘像素。
 * BORDER_REFLECT:       fedcba|abcdefgh|hgfedcb
 * BORDER_REFLECT_101:   gfedcb|abcdefgh|gfedcba//对称法,也就是以最边缘像素为轴,对称。
 * BORDER_WRAP:          cdefgh|abcdefgh|abcdefg
 * BORDER_CONSTANT:      iiiiii|abcdefgh|iiiiiii  with some specified 'i'//常量法。

Reference: https://blog.csdn.net/qq_22764813/article/details/52787553

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324064251&siteId=291194637
Recommended