Open VLourenco23 opened 2 years ago
#!/usr/bin/env python3
import numpy as np
import cv2
import matplotlib.pyplot as plt
# https://carla.readthedocs.io/en/stable/cameras_and_sensors/#camera-semantic-segmentation
# reads image 'opencv-logo.png' as grayscale
image = cv2.imread('test1.png', cv2.IMREAD_UNCHANGED)
print(type(image))
print(image.shape)
print(image.dtype)
cv2.imshow('image', image)
# extract red channel
b, g, r, _ = cv2.split(image)
# Search for roads
mask_0 = (r == 6).astype(np.uint8)*255
print(mask_0.dtype)
cv2.imshow('mask_0', mask_0)
cv2.waitKey(0)