提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一,实验步骤
1,打开python3
2,为了方便我们的实验和代码的编写,我们可以把要用到的图片直接保存在根目录中方便我们的直接使用
然后输入以下代码
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
%matplotlib inline
image = mpimg.imread('test.jpg.png')
plt.imshow(image)
r = image[:,:,0]
g = image[:,:,1]
b = image[:,:,2]
# 可视化各个颜色通道
f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(20,10))
ax1.set_title('R channel')
ax1.imshow(r, cmap='gray')
ax2.set_title('G channel')
ax2.imshow(g, cmap='gray')
ax3.set_title('B channel')
ax3.imshow(b, cmap='gray')
总结
可以很明显的感受到不同色块的通道级别不一样