[Python] Need to crop the text lines from handwritten image using opencv

Discussão em 'Python' iniciado por Stack, Novembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I have a image which having handwritten texts ... I need to fetch each lines as images from the image

    I used Opencv -> Erode,dilate and morph [​IMG] kernel = np.ones((2,2), np.uint8)

    adaptiveImage = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
    cv2.THRESH_BINARY, 9, 5)
    cv2.imshow("Adaptive Threshold", adaptiveImage)
    cv2.waitKey()

    median = cv2.medianBlur(adaptiveImage,3)
    cv2.imshow("median",median)
    cv2.waitKey()

    # adaptive_morph_open = cv2.morphologyEx(adaptiveImage, cv2.MORPH_OPEN, kernel)
    # cv2.imshow("adaptive_morph_open",adaptive_morph_open)
    # cv2.waitKey()


    adaptive_morph_close = cv2.morphologyEx(median, cv2.MORPH_CLOSE, kernel)
    cv2.imshow("adaptive_morph_close",adaptive_morph_close)
    cv2.waitKey()

    # drawBoxes(img,adaptive_morph_close)

    kernelHoriontal = cv2.getStructuringElement(cv2.MORPH_RECT, ksize=(5, 1))
    adaptiveDilated = cv2.erode(adaptive_morph_close, kernelHoriontal, iterations=12)

    Continue reading...

Compartilhe esta Página