python - 为什么/如何在 matplotlib imshow() 中使用 cmap 参数来隔离颜色 Pane ?

标签 python numpy matplotlib opencv

每当我绘制这张图像时,我都会遇到白色变黄的问题。我知道这是由于 matplotlib 使用的默认颜色映射 viridis 造成的。当我切换到 cmap='gray' 时,它最终显示右侧的红色 Pane 。

谁能解释一下为什么会发生这种情况?像这样的图片一般应该使用什么色图?当我执行默认的imshow(img)时,图片如何能够显示正确的颜色?当我隔离单一颜色 Pane 时会发生什么变化?当隔离图像中的红绿或蓝色 Pane 时,首选的 cmap 是什么?为什么?

Ipython Notebook

这是红色 Pane 的输出

常规图像根据 RGB 颜色模式正确绘制:

enter image description here

最佳答案

逻辑相当简单,下面的图表可能比任何解释更有帮助。

enter image description here

关于python - 为什么/如何在 matplotlib imshow() 中使用 cmap 参数来隔离颜色 Pane ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45829980/

相关文章:

android - 使用 Python 进行 Unicode URL 编码/解码

python列表+空numpy数组=空numpy数组?

python - 如何标记和更改 Seaborn kdeplot 轴的比例

python - 具有指定误报和灵敏度的随机森林

python - 在 python 中拆分列表

python - 优化 RPi.GPIO 中类似事件回调的代码部分(Raspberry Pi 上的 python)

Python 根据另一列中的 Nan 或 boolean 值在一列中移动值

python - nan、NaN和NAN有什么区别

python - mustache 被定义为 1.5* IQR,python seaborn boxplot 中的两个 mustache 怎么会不同呢?

python-2.7 - matplotlib.pyplot.plot() 和 matplotlib.pyplot.figure() 之间的区别?