gpt4 book ai didi

python - 如何在 OpenCV 中将 (1024,1024) 形状图像转换为 (1024,1024,3)

转载 作者:行者123 更新时间:2023-12-02 17:04:03 25 4
gpt4 key购买 nike

我有一个形状为 (1024,1024) 的单 channel 图像。

我想用形状 (1024,1024,3) 的彩色图像覆盖它dst = cv2.addWeighted(im, 1, newimg, 1, 0)
所以首先,我想知道,如何将 newimg 转换为 1024x1024x3...因为 im形状为 1024x1024x3

最佳答案

这似乎是使用 numpy 的一种简单解决方案。

Create a 3-channel black image

Put your same grayscale image into each channel
newimage = np.zeros((grayimage.shape[0],grayimage.shape[1],3))
newimage[:,:,0] = grayimage
newimage[:,:,1] = grayimage
newimage[:,:,2] = grayimage

how to copy numpy array value into higher dimensions

关于python - 如何在 OpenCV 中将 (1024,1024) 形状图像转换为 (1024,1024,3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57735396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com