[][src]Function opencv::core::copy_make_border

pub fn copy_make_border(
    src: &dyn ToInputArray,
    dst: &mut dyn ToOutputArray,
    top: i32,
    bottom: i32,
    left: i32,
    right: i32,
    border_type: i32,
    value: Scalar
) -> Result<()>

Forms a border around an image.

The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.

The function supports the mode when src is already in the middle of dst . In this case, the function does not copy src itself but simply constructs the border, for example:

   // let border be the same in all directions
   int border=2;
   // constructs a larger image to fit both the image and the border
   Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
   // select the middle part of it w/o copying data
   Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
   // convert image from RGB to grayscale
   cvtColor(rgb, gray, COLOR_RGB2GRAY);
   // form a border in-place
   copyMakeBorder(gray, gray_buf, border, border,
                   border, border, BORDER_REPLICATE);
   // now do some custom filtering ...
   ...

Note: When the source image is a part (ROI) of a bigger image, the function will try to use the pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as if src was not a ROI, use borderType | #BORDER_ISOLATED.

Parameters

  • src: Source image.
  • dst: Destination image of the same type as src and the size Size(src.cols+left+right, src.rows+top+bottom) .
  • top: the top pixels
  • bottom: the bottom pixels
  • left: the left pixels
  • 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.
  • borderType: Border type. See borderInterpolate for details.
  • value: Border value if borderType==BORDER_CONSTANT .

See also

borderInterpolate

C++ default parameters

  • value: Scalar()