main.py 文件源码

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

项目:document-layout-analysis 作者: rbaguila 项目源码 文件源码
def process_line(thresh,output):    
    # assign a rectangle kernel size    1 vertical and the other will be horizontal
    kernel = np.ones((1,5), np.uint8)
    kernel2 = np.ones((2,4), np.uint8)  
    # use closing morph operation but fewer iterations than the letter then erode to narrow the image   
    temp_img = cv2.morphologyEx(thresh,cv2.MORPH_CLOSE,kernel2,iterations=2)
    #temp_img = cv2.erode(thresh,kernel,iterations=2)   
    line_img = cv2.dilate(temp_img,kernel,iterations=5)

    (contours, _) = cv2.findContours(line_img.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)

    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 par by par boxing
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号