当前位置:网站首页>Opencv learning notes-day9 opencv's own color table operation (colormap coloraptypes enumeration data types and applycolormap() pseudo color function)
Opencv learning notes-day9 opencv's own color table operation (colormap coloraptypes enumeration data types and applycolormap() pseudo color function)
2022-06-30 08:47:00 【Chasing foot dream】
OpenCV Learning notes
OpenCV With color table operation
use OpenCV Bring your own color table to change the image color
function
OpenCV The definition of colormap( Chromaticity diagram ), Can be applied to grayscale images , Using functions applycolormap Generate pseudo color image .
// Definition ColormapTypes Enumerate data types
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 //!< 
};
Quote an example
int colormap[] = {
COLORMAP_AUTUMN,
COLORMAP_BONE,
COLORMAP_JET,
COLORMAP_WINTER,
COLORMAP_RAINBOW,
COLORMAP_OCEAN,
COLORMAP_SUMMER,
COLORMAP_SPRING,
COLORMAP_COOL,
COLORMAP_PINK,
COLORMAP_HOT,
COLORMAP_PARULA,
COLORMAP_MAGMA,
COLORMAP_INFERNO,
COLORMAP_PLASMA,
COLORMAP_VIRIDIS,
COLORMAP_CIVIDIS,
COLORMAP_TWILIGHT,
COLORMAP_TWILIGHT_SHIFTED,
};
// Definition
CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
| Parameters | explain |
|---|---|
| src | The source image ( Grayscale or color chart (CV_8UC1 or CV_8UC3)) |
| dst | The result image after color mapping on the source image |
| colormap | Color map code value provided ( See :ColormapTypes Enumerate data types ) |
example
applyColorMap(image,dst,colormap[index%20]);//index%20 Guarantee colorMap The parameters inside are colormap[0-19] Between , To facilitate the selection of members in enumeration data types
Code
#pragma once
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
using namespace cv;
// Defining classes
class QuickDemo{
public:
void colorSpace_Demo(Mat &image);// Color space conversion function 2021-12-24
void mat_creation_demo(Mat &image);//Mat Object and creation 2021-12-27
void pixel_vist_Demo(Mat &image);// Read and write operation of image pixels 2022-1-3
void operators_demo(Mat &image);// Arithmetic operation of image pixels 2022-1-4
void tracking_bar_demo(Mat &image);// Scroll bar operation demonstration 2022-1-7
void key_demo(Mat &image);// Keyboard response operation 2022-1-12
void color_style_demo(Mat &image);//OpenCV With color table operation 2022-1-12
};
QuickDemo.cpp
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
#include <iostream>
void QuickDemo::color_style_demo(Mat &image)
{
int colormap[] = {
COLORMAP_AUTUMN,
COLORMAP_BONE,
COLORMAP_JET,
COLORMAP_WINTER,
COLORMAP_RAINBOW,
COLORMAP_OCEAN,
COLORMAP_SUMMER,
COLORMAP_SPRING,
COLORMAP_COOL,
COLORMAP_PINK,
COLORMAP_HOT,
COLORMAP_PARULA,
COLORMAP_MAGMA,
COLORMAP_INFERNO,
COLORMAP_PLASMA,
COLORMAP_VIRIDIS,
COLORMAP_CIVIDIS,
COLORMAP_TWILIGHT,
COLORMAP_TWILIGHT_SHIFTED,
COLORMAP_HSV,
};
Mat dst;
int index = 0;
while (true)
{
int c = waitKey(1000);
if (c == 27){
break;
}
applyColorMap(image,dst,colormap[index%20]);//index%19 Guarantee colorMap The parameters inside are 0-18 Between
index++;
imshow(" Color style ", dst);
}
}
OpencvTest.cpp
#include <iostream>
#include <opencv2\highgui.hpp>
#include <opencv2\imgproc.hpp>
#include<quickopencv.h>
using namespace cv;
using namespace std;
int main()
{
Mat scr = imread("...\\image\\1.jpg");// Open a picture
if (!scr.data == 1)// Sentenced to empty
return -1;
namedWindow(" window 1", WINDOW_NORMAL);// establish WINDOW_FREERATIO window
imshow(" window 1",scr);// Show in the created window
QuickDemo qd;
qd.color_style_demo(scr);
waitKey(0);
return 0;
}
According to the effect
20 Color intervals 1 Seconds in sequence , Press ESC Key exit program
边栏推荐
- Maxiouassigner of mmdet line by line interpretation
- mysql基础入门 动力节点[老杜]课堂作业
- Mmdet line by line deltaxywhbboxcoder
- php api获取二维码、组合生成图片
- QT downloading files through URL
- Is the reverse repurchase of treasury bonds absolutely safe? How to open an account online
- Bind threads to run on a specific CPU logical kernel
- Source code interpretation of detectron2 1--engine
- codeforces每日5题(均1700)-第三天
- [nvme2.0b 14-8] set features (Part 2)
猜你喜欢

自制GIF动态图-gifcam

codeforces每日5题(均1700)-第三天

Mmcv expanding CUDA operator beginner level chapter

el-input 限制只能输数字

Build a docker image of Henkel database from 0

How can we get a satisfactory salary? These routines still need to be mastered

Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which

Interpretation of source code demand:a rotation equivariant detector for aerial object detection

El input limit can only input numbers

QT connection to Shentong database
随机推荐
Redis design and Implementation (III) | interaction between server and client (event IO model)
[untitled]
Graffiti Wi Fi & ble SoC development slide strip
CUDA realizes L2 European distance
[nvme2.0b 14-8] set features (Part 2)
【NVMe2.0b 14-2】Create/Delete Queue
Use Huawei performance management service to configure the sampling rate on demand
Redis design and Implementation (I) | data structure & object
Rew acoustic test (I): microphone calibration
Is the reverse repurchase of treasury bonds absolutely safe? How to open an account online
从0开始构建一个瀚高数据库Docker镜像
【kotlin 协程】万字协程 一篇完成kotlin 协程进阶
C#訪問SQL Server數據庫兩種方式的比較(SqlDataReader vs SqlDataAdapter)
Bind threads to run on a specific CPU logical kernel
Detectron2 source code reading 4-- registrar construction model
国债逆回购绝对安全吗 网上怎么开户
C # listbox how to get the selected content (search many invalid articles)
Flink SQL custom connector
Rew acoustic test (IV): test principle of rew
Self made GIF dynamic graph -gifcam