Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to make a custom kernel for extraction?

Hello,

I use morphological opening to extract horizontal lines from my image:

<...uploading an image and binarizing it...>    
kernel_2 = np.ones((1,7), np.uint8)
hor_opening = cv2.morphologyEx(binary_img, cv2.MORPH_OPEN, kernel)

It works perfectly, but what should I do to use a kernel that combines ones and zeros? I want to extract from my image all segments that satisfy a following mask: [0, 1, 1, 1, 1, 1, 1, 1, 0]