Crop text out of binary image OpenCV C++
问题 How can I crop the image so that only the text is included in the image using OpenCV? 回答1: Approach Dilating the image in in the vertical and horizontal direction Finding the bounding rectangle Cropping the image Code # reading the input image in grayscale image image = cv2.imread('image2.png',cv2.IMREAD_GRAYSCALE) image /= 255 if image is None: print 'Can not find/read the image data' # Defining ver and hor kernel N = 5 kernel = np.zeros((N,N), dtype=np.uint8) kernel[2,:] = 1 dilated_image =