kitti和cityscape的gt的分割不太一样,下边缘不再是从黑色开始的,而是直接是类别

red,green,blue = img_gt[i,j]

1.道路的颜色(紫色):128 64 128

2.汽车的颜色(蓝色):142 0 0
3.人行道的颜色(朱红色):232 35 244
4.树和绿色植物的颜色(绿色):35 142 107

5.灰色:70 70 70

6.绿地(浅绿色):152 251 152

7.石子路(肉色、浅粉红色):160 170 250

8.另一种石子路(土褐色):81 0 81(图83_10.png)

75_10.png这张图中黄色柱状物下面的图黄色那部分如何处理其实是一个很大的问题,处理掉,但是确实这个东西有高度,不处理掉,那上面的柱状物体就检测不出来

要处理的有3,6,7,8

处理代码和之前在cityscape的略微有点不同:

import cv2
import numpy as np with open('/media/hdc/xing/data_semantics/training/semantic_rgb/a.txt','r') as file:
# num = 0
for line in file:
# if num == 1:
# break
# num += 1
gt_image = '/media/hdc/xing/data_semantics/training/semantic_rgb/' + line.strip().split('./')[1]
# print gt_image
save_dir = '/media/hdc/xing/data_semantics/training/label012/' + line.strip().split('./')[1]
img_gt = cv2.imread(gt_image)
# print type(img_gt)
height = img_gt.shape[0]
width = img_gt.shape[1]
# print width,height
result = np.zeros((height,width))
for i in range(width):
index = height-1
red,green,blue = img_gt[index,i]
# print i,red,green,blue
while index >= 1 and (red != 128 or green != 64 or blue != 128):
index -= 1
red,green,blue = img_gt[index,i]
while index >= 1 and red == 128 and green == 64 and blue == 128:
index -= 1
result[index][i] = 1
# result[index][i] = 255
red,green,blue = img_gt[index,i]
while (index >= 1 and red == 232 and green == 35 and blue == 244) or (index >= 1 and red == 152 and green == 251 and blue == 152) or (index >= 1 and red == 160 and green == 170 and blue == 250) or (index >= 1 and red == 81 and green == 0 and blue == 81):
index -= 1
red,green,blue = img_gt[index,i]
while index >= 1 and red == 128 and green == 64 and blue == 128:
index -= 1
result[index][i] = 1
# result[index][i] = 255
red,green,blue = img_gt[index,i]
blue1 = blue
green1 = green
red1 = red
# print blue1,green1,red1
while index >= 1 and blue == blue1 and green == green1 and red == red1:
result[index][i] = 2
# result[index][i] = 150
index -= 1
red,green,blue = img_gt[index,i]
while index >= 1 and red == 128 and green == 64 and blue == 128:
index -= 1
result[index][i] = 1
# result[index][i] = 255
red,green,blue = img_gt[index,i]
while index >= 1 and blue == blue1 and green == green1 and red == red1:
result[index][i] = 2
# result[index][i] = 150
index -= 1
red,green,blue = img_gt[index,i]
# while index >= 1 and (red != 128 or green != 64 or blue != 128):
# index -= 1
# red,green,blue = img_gt[index,i]
# while index >= 1 and red == 128 and green == 64 and blue == 128:
# index -= 1
# # result[index][i] = 1
# result[index][i] = 255
# red,green,blue = img_gt[index,i]
# while index >= 1 and red == 250 and green == 170 and blue == 160:
# index -= 1
# red,green,blue = img_gt[index,i]
# while index >= 1 and red == 244 and green == 35 and blue == 232:
# index -= 1
# red,green,blue = img_gt[index,i]
# while index >= 1 and red == 152 and green == 251 and blue == 152:
# index -= 1
# red,green,blue = img_gt[index,i]
# blue2 = blue
# green2 = green
# red2 = red
# while index >= 1 and blue == blue2 and green == green2 and red == red2:
# index -= 1
# # result[index][i] = 2
# result[index][i] = 150
# red,green,blue = img_gt[index,i]
# print index
for i in range(width):
for j in range(height):
red,green,blue = img_gt[j,i]
if blue == 0 and green == 0 and red == 0:
result[j][i] = 0
cv2.imwrite(save_dir,result)
print save_dir

最新文章

  1. Django 权限管理
  2. ABP理论学习之NHibernate集成
  3. Struts2 Result 类型和对应的用法详解
  4. C# 中的"yield"使用
  5. linux常识以及常用命令和参数
  6. 让网站变灰的CSS代码(支持IE、FIREFOX和CHROME)
  7. 数据挖掘:实用机器学习技术P295页:
  8. rnqoj-49-加分二叉树-(区域动归+记忆化)
  9. 理解zookeeper选举机制
  10. 在WPF应用程序中使用Font Awesome图标
  11. python中的turtle库(图形绘画库)
  12. 上传--spring-boot
  13. js 正则表达式的使用(标志 RegExp exec() test() compile() $1...$9)
  14. 为什么fork()2次会避免产生僵尸进程
  15. 20155228 实验四 Android开发基础
  16. 42-字符串到json 的错误 com.alibaba.fastjson.JSONObject cannot be cast to java.lang.String
  17. docker私服搭建nexus3
  18. .net core Web应用启动类
  19. js如何获取键盘高度
  20. mmap函数使用

热门文章

  1. 转 如何在secureCRT上设置常用的快捷输出按钮栏听语音
  2. 3dsmax 卸载/安装失败/出错 2019/2018/2017/2016/2015/2013/2012
  3. CSS选择器笔记,element element和element > element 的区别
  4. swing线程机制
  5. js的事件冒泡
  6. node搭环境(四)--webpack启服务运行VUE模块文件(手写简单脚手架)
  7. Python四大神兽(迭代器&生成器&闭包&装饰器)
  8. Container&injection(容器与注入思想)
  9. Redis的原子自增性
  10. 在使用angular和swiper插件中的一些问题