我想在一个三通道的RGB图像上添加一个带有骨架像素值为255(白色)的黑白骨架图像。我并不倾向于使用OpenCV,但是当我使用加法函数时,我收到了形状不兼容的错误提示。
如何实现这个功能呢?
import cv2
skl_img = cv2.imread("sample_skeleton_image/579366_2_train2017_skel.png", 0)
print(skl_img.shape)
plt.imshow(skl_img)
224x400
obj_img = cv2.imread("/content/drive/Shareddrives/Wish 2021/Code/sample_skeleton_image/579366_2_train2017.jpg", cv2.IMREAD_COLOR)
plt.imshow(obj_img)
obj_img 的形状为 224x400x3
final_img = cv2.add(obj_img,skl_img)
plt.imshow(final_img)
error Traceback (most recent call last)
<ipython-input-27-7de7a4136982> in <module>()
----> 1 final_img = cv2.add(obj_img,skl_img)
2 plt.imshow(final_img)
error: OpenCV(4.1.2) /io/opencv/modules/core/src/arithm.cpp:663: error: (-209:Sizes of input arguments do not match) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op'