【发布时间】:2020-03-18 10:19:25
【问题描述】:
我正在尝试仅使用 Matplotlib.pyplot 和 NumPy 显示图像的红色通道。谁能解释一下,为什么我得到以下两个代码的不同图像?
代码 #1:
R = numpy.copy(img) # copy image into new array
R[:,:,1]=0 # set green channel to 0
R[:,:,2]=0 # set blue channel to 0
matplotlib.pyplot.imshow(R)
matplotlib.plyplot.show() # display new image
代码 #2:
R = numpy.zeros(img.shape) # create array of 0-s with same dimensions as image
R[:,:,0]=img[:,:,0] # copy red channel values into array of 0-s
matplotlib.pyplot.imshow(R)
matplotlib.plyplot.show() # display new image
【问题讨论】:
标签: python image numpy matplotlib matrix