Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def denoise_pass(self, img, min_size):
- nb_components, labels, stats, centroids = \
- cv.connectedComponentsWithStats(img, connectivity=8)
- sizes = stats[1:, -1]
- nb_components = nb_components - 1
- img2 = np.zeros(labels.shape, dtype=np.uint8)
- for i in range(0, nb_components):
- if sizes[i] >= min_size:
- img2[labels == i + 1] = 255
- return(img2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement