You are here

Přidat komentář

import cv2
import numpy

img = cv2.imread("Stresova-Zlomalovanka.png")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.threshold(gray, 128, 255, cv2.THRESH_BINARY, dst=gray)
_, markers = cv2.connectedComponents(gray, connectivity=4)
img = cv2.cvtColor(markers.astype("uint8"), cv2.COLOR_GRAY2BGR)
lut = numpy.random.randint(0, 255, (1, 256, 3)).astype("uint8")
lut[0, 0, :] = 0
cv2.LUT(img, lut, img)

cv2.imshow("zlo", img)
cv2.waitKey()