当前位置:网站首页>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
边栏推荐
- [untitled]
- 【付费推广】常见问题合集,推荐榜单FAQ
- 挖财开户安全吗?怎么有人说不靠谱。
- 证券开户的优惠怎样才能得到?在线开户安全?
- Detailed explanation of pipline of mmdetection
- 【NVMe2.0b 14-4】Directive Send/Receive command
- Advanced technology management -- how managers design and build echelons
- Introduction to MySQL basics day3 power node [Lao Du] class notes
- CUDA implements matrix replication
- 电流探头的干扰源电流谱测试
猜你喜欢
我们如何拿到自己满意的薪资呢?这些套路还是需要掌握的
Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush
【NVMe2.0b 14-2】Create/Delete Queue
[nvme2.0b 14-7] set features (Part 1)
Interpretation of source code demand:a rotation equivariant detector for aerial object detection
Does the oscilloscope probe affect the measurement of capacitive load?
Mmdet line by line deltaxywhbboxcoder
使用华为性能管理服务,按需配置采样率
Redis design and Implementation (II) | database (deletion strategy & expiration elimination strategy)
Axure make menu bar effect
随机推荐
TiDB 6.0:让 TSO 更高效丨TiDB Book Rush
技术管理进阶——管理者如何进行梯队设计及建设
国债逆回购绝对安全吗 网上怎么开户
Resnet50+fpn for mmdet line by line code interpretation
Unity 基础光照模型
Interpretation of orientedrcnn papers
Flink SQL custom connector
Enter the URL in the browser and display it on the page
[untitled]
[untitled]
Mmcv expanding CUDA operator beginner level chapter
[nvme2.0b 14-7] set features (Part 1)
Influencing factors of echo cancellation for smart speakers
挖财开户安全吗?怎么有人说不靠谱。
127.0.0.1, 0.0.0.0 and localhost
Detailed explanation of pipline of mmdetection
Codeworks 5 questions per day (1700 for each) - the third day
酒精测试仪方案:酒精测试仪是根据什么原理测酒精溶度?
[untitled]
[data analysis and display]