当前位置:网站首页>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
边栏推荐
- Be careful of this hole in transmittable thread local
- Is it safe to open an account? How can anyone say that it is not reliable.
- Redis设计与实现(一)| 数据结构 & 对象
- CUDA implements matrix replication
- Source code interpretation of detectron2 1--engine
- Mmdet line by line code interpretation of positive and negative sample sampler
- Redis design and Implementation (VI) | cluster (sharding)
- Redis design and Implementation (I) | data structure & object
- Interference source current spectrum test of current probe
- 电流探头电路分析
猜你喜欢

电流探头电路分析

从0开始构建一个瀚高数据库Docker镜像

云服务器上部署仿牛客网项目

QT connection to Shentong database

A troubleshooting of CPU bottom falling

Deploy the cow like customer network project on the ECS

el-input 限制只能输数字

Rew acoustic test (VI): signal and measurement

Graffiti Wi Fi & ble SoC development slide strip

Does the oscilloscope probe affect the measurement of capacitive load?
随机推荐
Dart tips
2021-02-22
2021-02-27
Pytorch BERT
Is it safe to open an account? How can anyone say that it is not reliable.
Gilbert Strang's course notes on linear algebra - Lesson 2
Pytorch BERT
QT downloading files through URL
酒精测试仪方案:酒精测试仪是根据什么原理测酒精溶度?
Rew acoustic test (II): offline test
Unity 基础光照模型
2021-04-29
Evaluation standard for audio signal quality of intelligent speakers
Detectron2 source code reading 4-- registrar construction model
Self made GIF dynamic graph -gifcam
Viteproject require Syntax Compatibility Problem Solving require is not defined
【NVMe2.0b 14-4】Directive Send/Receive command
[nvme2.0b 14-7] set features (Part 1)
CUDA realizes matrix multiplication
维基媒体基金会公布新商业产品“维基媒体企业”首批客户