
我想创建一个新的交错图像,奇数行属于一个图像,偶数行属于另一个图像。我正在尝试用python、openCv和numpy来做到这一点!读取1图像,并使用循环尝试写入奇数和偶数行中的值。我不知道该怎么做。你有什么建议吗?
发布于 2017-05-09 07:15:04
下面是一个例子
import numpy as np
from matplotlib import pyplot as plt
imgshape = (100,100,3)
blue = np.zeros(imgshape)
red = np.zeros(imgshape)
blue[:,:,2] = np.ones(blue.shape[:2])
red[:,:,0] = np.ones(blue.shape[:2])
mix = np.zeros(imgshape)
oddrows = [i for i in range(blue.shape[0]) if i %2==1]
evenrows = [i for i in range(blue.shape[0]) if i%2==0]
mix[oddrows] = red[oddrows]
mix[evenrows] = blue[evenrows]
plt.imshow(mix)https://stackoverflow.com/questions/43852556
复制相似问题