我想在照片上添加预先生成的热图。图像中的颜色并不重要,为了使热图颜色突出,我将图像设为灰度。我已经使用
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
但是,与热图(BRG)相比,灰度图像现在的尺寸要少一维。如何在灰色图像上叠加热图?
答案 0 :(得分:1)
在两个相同大小和模式的图像就位后,执行以下代码。
from PIL import Images
im_1 = Image.open("/constr/pics1/100_canary.png")
# mode is RGBA
im_2 = Image.open("/constr/pics1/100_cockcrow.png")
# Check on mode, size and format first for compatibility.
# Make both modes the same
im_4 = Image.blend(im_1, im_2, 0.5)
im_4.show()