RGB通道可视化

一、实验介绍

1. 实验内容

本实验将介绍RGB色彩空间。

2. 实验要点

  • RGB通道

3. 实验环境

  • Python 3.6.6
  • matplotlib

二、实验步骤

导入资源

import matplotlib.pyplot as plt
import matplotlib.image as mpimg

%matplotlib inline

读入图像

# 读入该图像
image = mpimg.imread('images/wa_state_highway.jpg')

plt.imshow(image)
<matplotlib.image.AxesImage at 0x7f01bd6ca8d0>

在这里插入图片描述

RGB通道

可视化每个颜色通道的级别。 注意交通标志!

# 隔离RGB通道
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')

## 哪个区域的红色值最低? 蓝呢?
<matplotlib.image.AxesImage at 0x7f016f3382b0>

在这里插入图片描述

三、实验任务

讨论

请仔细思考,上述图片哪个区域的红色值最低? 蓝呢?

扫描二维码关注公众号,回复: 15523000 查看本文章
离我们最近的小车红色最低,小车上面的警示牌蓝色最低。一般在一个通道下,其颜色越浅说明其通道值越高。

猜你喜欢

转载自blog.csdn.net/qq_52215423/article/details/131024356
今日推荐