当前位置:网站首页>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 .

边栏推荐
- StrictMode卡顿与泄漏检测-StrictMode原理(2)
- Q play soft large toast to bring more comfortable sleep
- 闭锁继电器YDB-100、100V
- Xjy-220/43ac220v static signal relay
- JS to convert numbers into Chinese characters for output
- 06. on several ways of redis persistence
- Dls-20 double position relay 220VDC
- DLS-42/6-4 DC110V双位置继电器
- [LeetCode] 爬楼梯【70】
- 冲击继电器ZC-23/DC220V
猜你喜欢

Two-stage RO: part 1

Packing and unpacking of C #

The quantity and quality of the devil's cold rice 101; Employee management; College entrance examination voluntary filling; Game architecture design

【网络丢包,网络延迟?这款神器帮你搞定所有!】

基础知识之三——标准单元库

DX-11Q信号继电器

集群与LVS介绍及原理解析
![Parity linked list [two general directions of linked list operation]](/img/4e/ce860bc172bb75f456427ba26a7842.png)
Parity linked list [two general directions of linked list operation]

ESP8266 RC522

Poor students can also play raspberry pie
随机推荐
Two position relay st2-2l/ac220v
Poor students can also play raspberry pie
Unhandled Exception: MissingPluginException(No implementation found for method launch on channel)
Share your own terminal DIY display banner
NE555 waveform generator handle tutorial NE555 internal structure (I)
Q弹松软的大号吐司,带来更舒服的睡眠
使用StrictMode-StrictMode原理(1)
ArrayList analysis 1-cycle, capacity expansion, version
Cmu15445 (fall 2019) project 1 - buffer pool details
ORB-SLAM2源码学习(二)地图初始化
User defined annotation implementation verification
[learning notes] simple DP
CSDN common complex formula template record
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
Left join displays the specified value when the left join matching data is null
2022 is half way through. It's hard to make money
Dx-11q signal relay
DLS-20型双位置继电器 220VDC
StrictMode卡顿与泄漏检测-StrictMode原理(2)
[go] go implements row column conversion of sets