March 2018
Beginner to intermediate
306 pages
9h 54m
English
In order to execute this recipe, we will perform the following steps:
import cv2import numpy as np
img = cv2.imread('../data/BnW.png', cv2.IMREAD_GRAYSCALE)connectivity = 8num_labels, labelmap = cv2.connectedComponents(img, connectivity, cv2.CV_32S)
img = np.hstack((img, labelmap.astype(np.float32)/(num_labels - 1)))cv2.imshow('Connected components', img)cv2.waitKey()cv2.destroyAllWindows()
img = cv2.imread('../data/Lena.png', cv2.IMREAD_GRAYSCALE)otsu_thr, otsu_mask ...