我想创建一个新的隔行扫描图像,其中奇数行属于一个图像,偶数行属于另一个图像。我试图用python和openCv和numpy做到这一点!读取一个图像并使用循环我尝试在奇数行和偶数行中写入值。我不知道该怎么做。你有一些提示吗?p
答案 0 :(得分:0)
这是一个例子
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)