main.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:document-layout-analysis 作者: rbaguila 项目源码 文件源码
def process_letter(thresh,output):  
    # assign the kernel size    
    kernel = np.ones((2,1), np.uint8) # vertical
    # use closing morph operation then erode to narrow the image    
    temp_img = cv2.morphologyEx(thresh,cv2.MORPH_CLOSE,kernel,iterations=3)
    # temp_img = cv2.erode(thresh,kernel,iterations=2)      
    letter_img = cv2.erode(temp_img,kernel,iterations=1)

    # find contours 
    (contours, _) = cv2.findContours(letter_img.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

    # loop in all the contour areas
    for cnt in contours:
        x,y,w,h = cv2.boundingRect(cnt)
        cv2.rectangle(output,(x-1,y-5),(x+w,y+h),(0,255,0),1)

    return output   


#processing letter by letter boxing
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号