当前位置:网站首页>Opencv basic operation 2 realizes label2rgb and converts gray-scale images into color images
Opencv basic operation 2 realizes label2rgb and converts gray-scale images into color images
2022-07-01 01:21:00 【Ten thousand miles and a bright future arrived in an instant】
All the images obtained by semantic segmentation are gray-scale images , It is not conducive to viewing the segmentation effect , Through to label The value changes linearly three times , You can get information about R、G、B Pseudo color of three channels , Then generate a pseudo color image .
The specific code is as follows : For different class_num Of label Data sets , Just adjust the code class_num that will do
cv::Mat set_color(cv::Mat label) {
int class_num = 8;// One has 8 Categories
int color_setp = int(255 / class_num);
cv::Mat tmp,bg;
label.copyTo(tmp);
// Set the background to white
// Put more than 0 All the parts of the are assigned to 0, Less than or equal to 0 The part of is assigned as 255
threshold(tmp, bg, 0, 255, THRESH_BINARY_INV);
cv::Mat G = (class_num - label) * color_setp;
cv::Mat R = label * color_setp;
cv::Mat B = (R + G) / 2;
B.convertTo(B, CV_8UC1);
// Let the background be white
vector<cv::Mat> mv;
mv.push_back(R + bg);
mv.push_back(G + bg);
mv.push_back(B + bg);
cv::Mat RGB;
cv::merge(mv, RGB);
return RGB;
}The effect of the generated pseudo color image is shown in the figure 1 Shown , The background is white .

边栏推荐
- [learning notes] structure
- Analyze the maker education path integrating the essence of discipline
- None of the following candidates is applicable because of a receiver type mismatch
- Xjy-220/43ac220v static signal relay
- Q play soft large toast to bring more comfortable sleep
- 【学习笔记】简单dp
- Openmv and k210 of the f question of the 2021 video game call the openmv API for line patrol, which is completely open source.
- Listview in flutter application development
- Oracle temporary table explanation
- Open3D 点云包围盒
猜你喜欢

ESP8266 RC522

Xjy-220/43ac220v static signal relay

Technical personnel advanced to draw a big picture of business, hand-in-hand teaching is coming

New content violation degree determination scana bad information monitoring capability update issue 5
![[original] PLSQL index sorting optimization](/img/91/dcd0262705a19645f1a87d4cf03bc8.jpg)
[original] PLSQL index sorting optimization
![[go] go implements row column conversion of sets](/img/d9/6272e55b2d9c6b6fbdf2537773bb83.png)
[go] go implements row column conversion of sets

Oracle table creation and management

HDU 2488 A Knight's Journey(DFS)

【学习笔记】倍增 + 二分

【go】go 实现行专列 将集合进行转列
随机推荐
NE555 waveform generator handle tutorial NE555 internal structure (I)
What if the disk of datanode is full?
Unhandled Exception: MissingPluginException(No implementation found for method launch on channel)
小程序自定义宫格
High quality pump SolidWorks model material recommended, not to be missed
用Steam教育启发学生多元化思维
双位置继电器DLS-5/2 DC220V
The real topic of the 11th provincial competition of Bluebridge cup 2020 - crop hybridization
pytorch编程知识(2)
Problem solving: how to manage thread_local pointer variables
ESP8266 RC522
Get to know the drawing component of flutter - custompaint
孔乙己第一问之服务通信知多少?
TCP三次握手为什么不是两次或四次
Service
[learning notes] double + two points
基础知识之二——STA相关的基本定义
[LeetCode] 两数之和【1】
[LeetCode] 爬楼梯【70】
关于VCTK数据集