code: def centerize(src, dst_shape, margin_color=None):
      
      if src.shape[:2] == dst_shape[:2]:
          return src
      centerized = np.zeros(dst_shape, dtype=src.dtype)
      if margin_color:
          centerized[:, :] = margin_color
      pad_vertical, pad_horizontal = 0, 0
      h, w = src.shape[:2]
      dst_h, dst_w = dst_shape[:2]
      if h < dst_h:
          pad_vertical = (dst_h - h) // 2
      if w < dst_w:
          pad_horizontal = (dst_w - w) // 2
      centerized[pad_vertical:pad_vertical + h,
                 pad_horizontal:pad_horizontal + w] = src
      return centerized
docs: Centerize image for specified image size
  
      @param src: image to centerize
      @param dst_shape: image shape (height, width) or (height, width, channel)