How to connect broken lines in a binary image using Python / Opencv

How can I connect these lines to target points? The image is the result of the skeletonization process.

Resulting Image From Skeletonization

Points That I Need To Connect

I am trying to segment each row as a region using the Watershed transform.

+8
source share
2 answers

MikeE : .
, . , / , , , .

( , bw):

import cv2, numpy as np

kernel = np.ones((1,20), np.uint8)  # note this is a horizontal kernel
d_im = cv2.dilate(bw, kernel, iterations=1)
e_im = cv2.erode(d_im, kernel, iterations=1) 

, , :
enter image description here

,

:
enter image description here

, /, .
, :
enter image description here

, , , .

+9

Source: https://habr.com/ru/post/1676697/


All Articles