当前位置:网站首页>Opencv has its own color operation
Opencv has its own color operation
2022-07-24 17:08:00 【When will we get ashore?】
The sample code is as follows :
void demo::color_style(Mat& image)
{
int colormap[] = {
COLORMAP_AUTUMN,
COLORMAP_BONE,
COLORMAP_CIVIDIS,
COLORMAP_COOL,
COLORMAP_HOT,
COLORMAP_HSV,
COLORMAP_INFERNO,
COLORMAP_JET,
COLORMAP_MAGMA,
COLORMAP_OCEAN,
COLORMAP_PARULA,
COLORMAP_PINK,
COLORMAP_PLASMA,
COLORMAP_RAINBOW,
COLORMAP_SPRING,
COLORMAP_SUMMER,
COLORMAP_TWILIGHT,
COLORMAP_TWILIGHT_SHIFTED,
COLORMAP_VIRIDIS,
COLORMAP_WINTER};
Mat dsc;
int index = 0;
while (true)
{
int c = waitKey(500);
if (c == 27)
break;
applyColorMap(image, dsc, colormap[index % 20]);
index++;
imshow(" Image type ", dsc);}
}
Here's the point applyColorMap() function , It states in imgproc.hpp
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
In front of the definition of this function above , We can also see the following :
enum ColormapTypes
{
COLORMAP_AUTUMN = 0, //!< 
COLORMAP_BONE = 1, //!< 
COLORMAP_JET = 2, //!< 
COLORMAP_WINTER = 3, //!< 
COLORMAP_RAINBOW = 4, //!< 
COLORMAP_OCEAN = 5, //!< 
COLORMAP_SUMMER = 6, //!< 
COLORMAP_SPRING = 7, //!< 
COLORMAP_COOL = 8, //!< 
COLORMAP_HSV = 9, //!< 
COLORMAP_PINK = 10, //!< 
COLORMAP_HOT = 11, //!< 
COLORMAP_PARULA = 12, //!< 
COLORMAP_MAGMA = 13, //!< 
COLORMAP_INFERNO = 14, //!< 
COLORMAP_PLASMA = 15, //!< 
COLORMAP_VIRIDIS = 16, //!< 
COLORMAP_CIVIDIS = 17, //!< 
COLORMAP_TWILIGHT = 18, //!< 
COLORMAP_TWILIGHT_SHIFTED = 19 //!< 
};
It can be found in the definition colormap( Chromaticity diagram ) When , Enumeration used , So we can define a int Type to store 20 Kind of colormap.
The index of the array is from 0 At the beginning , So it is index%20, If it is index%21 You're going to report a mistake .
applyColormap() The first parameter of the function is the input image , The second parameter is the output image , The third parameter is the provided color map code value .( Namely colormap Enumeration type in )
applyColorMap() Function has another use :
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, InputArray userColor);
userColor: Custom colors (CV_8UC1 or CV_8UC3 and size 256).
Result display :

over!!!
边栏推荐
猜你喜欢

Axi protocol (2): five channels and two transactions of Axi architecture

Xxx.pro learning in QT

ufw 端口转发

mysql 查询某字段中以逗号分隔的字符串的方法

quick get start

Method of querying comma separated strings in a field by MySQL

Internet Download Manager Configuration

Using unity to do simulation, I don't allow this chart plug-in, you don't know

Analyze the capabilities and scenarios of Apache pulsar, a cloud native message flow system

一个实际使用SwiftUI 4.0中ViewThatFits自适应视图的例子
随机推荐
电脑监控是真的吗?4个实验一探究竟
Pat a - correct spelling
Duplicate content in lookup table
Shardingsphere database read / write separation
Concept of IP, classification of IP, IP multiplexing technology
Analyze the capabilities and scenarios of Apache pulsar, a cloud native message flow system
ROS主从机通信经验总结
HCNP Routing&Switching之DHCP中继
双亲委派机制
NATBypass 端口转发
AXI协议(2):AXI架构的五个通道和两种事务
【GNN报告】腾讯AI lab 徐挺洋:图生成模型及其在分子生成中的应用
[GNN report] Tencent AI Lab Xu TingYang: graph generation model and its application in molecular generation
Comparison of array and object merging methods assign, merge, defaults, defaultsdeep in lodash
Win10 download address
Work with growingio engineers this time | startdt Hackathon
709. Convert to lowercase letters
How to effectively avoid memory leakage when customizing the handler?
Method of querying comma separated strings in a field by MySQL
Cross server, insert, search