python中有OpenCV颜色图吗? [英] Is there OpenCV colormap in python?

查看:97
本文介绍了python中有OpenCV颜色图吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 MatC,OpenCV中的matplotlib样式颜色图.该文档说明了其在C ++中的用法.我想知道是否也存在使用cv2的python这样的选项.我在Google上搜索了很多东西,却一无所获.我知道我可以使用matplotlib的colormap选项,但是如果cv2提供了这样的选项,则可以消除将matplotlib色图转换为opencv图像的开销.它笨拙.我的项目需要它.

I am aware of Matlab, matplotlib style colormap in OpenCV . The documentation explains its usage for C++. I was wondering if such an option exists for python using cv2 as well. I googled a lot to find nothing. I am aware of matplotlib's colormap option that I can use but if cv2 provides such option, I can remove the overhead of converting the matplotlib colormaps to opencv images. Its clumsy. I require it for my project.

推荐答案

对于OpenCV 2.4.11,applyColorMap在Python中工作(即使

For OpenCV 2.4.11, applyColorMap works in Python (even though the 2.4.11 docs still list only C++):

import cv2
im = cv2.imread('test.jpg', cv2.IMREAD_GRAYSCALE)
imC = cv2.applyColorMap(im, cv2.COLORMAP_JET)

另请参见此堆栈溢出答案.

这篇关于python中有OpenCV颜色图吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆