As we all know, OpenCV uses a differnt order of color channels (b, r, g,) not (r, b, g) for a historical reason. But I find that in python version, the second parameter of cv.copyMakeBorder, namely 'value', uses (r, b, g) as its order of color channels, which is inconsistent with other APIs and confused me.
So maybe there is a typo or a tiny mistake in the tutorial for Python tutorial_py_basic_ops. The tutorial provides a code snippet as shown below to teach the usage of funtion cv.copyMakeBorder.
import cv2 as cv import numpy as np from matplotlib import pyplot as plt BLUE = [255,0,0] img1 = cv.imread('opencv-logo.png') replicate = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_REPLICATE) reflect = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_REFLECT) reflect101 = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_REFLECT_101) wrap = cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_WRAP) constant= cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_CONSTANT,value=BLUE) plt.subplot(231),plt.imshow(img1,'gray'),plt.title('ORIGINAL') plt.subplot(232),plt.imshow(replicate,'gray'),plt.title('REPLICATE') plt.subplot(233),plt.imshow(reflect,'gray'),plt.title('REFLECT') plt.subplot(234),plt.imshow(reflect101,'gray'),plt.title('REFLECT_101') plt.subplot(235),plt.imshow(wrap,'gray'),plt.title('WRAP') plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANT') plt.show()
The author names a variable called 'BLUE' and assigns [255, 0, 0] to it which is sensible in the first glance. Then the variable 'BLUE' is used in
constant= cv.copyMakeBorder(img1,10,10,10,10,cv.BORDER_CONSTANT,value=BLUE)
in order to add a pure blue border to img1.
However, we get a pure red border at last which titled 'CONSTANT' in the bottom-right corner of the whole final result picture.
So may I fork the github repository and replace the variable name 'BLUE' with 'RED' to keep semantic consistency of the tutorial?