使用Matplotlib与Python
2014-03-26 21:49
531 查看
import numpy as np import cv2 from matplotlib import pyplot as plt im = cv2.imread('lena.jpg',cv2.CV_LOAD_IMAGE_GRAYSCALE) plt.imshow(im) plt.xticks([]),plt.yticks([]) plt.show()
import numpy as np import cv2 from matplotlib import pyplot as plt im = cv2.imread('lena.jpg',0) plt.imshow(im,'gray') plt.xticks([]),plt.yticks([]) plt.show()
Color image loaded by OpenCV is in BGR mode. But Matplotlib displays in RGB mode. So color
images will not be displayed correctly in Matplotlib if image is read with OpenCV
There is a slight difference in pixel ordering in OpenCV and Matplotlib.
OpenCV follows BGR order, while matplotlib likely follows RGB order.
So when you display an image loaded in OpenCV using pylab functions, you may need to convert it into RGB mode. ( I am not sure if any easy method is there). Below method demonstrate it:
Using Matplotlib :
Using
OpenCV :
相关文章推荐
- 使用 python Matplotlib
- Python 使用matplotlib 画数学公式图与散点图
- Python Matplotlib的安装使用及Scipy,numpy,dateutil,pyparsing的安装
- 在python3.3中使用matplotlib的安装方式
- python matplotlib绘图使用中文字体
- python3 matplotlib和seaborn的使用记录
- python实战二:使用CSV数据绘制带数据标志的折线图(matplotlib)
- Python绘图问题:Matplotlib中%matplotlib inline是什么、如何使用?
- Python使用matplotlib填充图形指定区域代码示例
- 使用 python Matplotlib 库绘图
- Python使用matplotlib填充图形指定区域
- 使用 Python 的 matplotlib 绘图库进行绘图
- python 数据可视化 matplotlib学习三:生成随机漫步数据并使用matplotlib呈现
- Python使用matplotlib实现绘制自定义图形功能示例
- Python使用matplotlib绘图示例
- Python使用matplotlib绘制三维曲线
- python使用matplotlib 以及matplotlib安装绘图(window7)
- python3 使用matplotlib画图出现中文乱码的情况
- python使用matplotlib绘制折线图教程
- Python 使用matplotlib画图添加标注、及移动坐标轴位置