Eliminating Interferential Curve of Text in Images?

天大地大妈咪最大 提交于 2019-12-12 04:07:32

问题


As you can see,I have an image of some formulas

but it has some interferential curve,so how can I to remove it?

I tried to erode and dilate but failed.


回答1:


You can remove those lines by using image inpainting. But need to make a mask first. Take a look at this- http://docs.opencv.org/trunk/df/d3d/tutorial_py_inpainting.html

I just tried one see-

This code (python) helps you make a mask:

import cv2
import numpy as np
imgg=cv2.imread("your_image.png")
flag = False
def draw(event,x,y,flags,param):
    global flag

    if event == cv2.EVENT_LBUTTONDOWN:
        flag = True

    elif event == cv2.EVENT_MOUSEMOVE:
        if flag == True:
                cv2.circle(img,(x,y),2,(255,255,255),-1)

    elif event == cv2.EVENT_LBUTTONUP:
        flag = False

img = np.zeros(imgg.shape[:2], np.uint8)
cv2.namedWindow('image')
cv2.setMouseCallback('image',draw)

while(1):
    cv2.imshow('image',imgg)
    cv2.imshow("mask",img)
    if(cv2.waitKey(1))==27:
        break
cv2.imwrite("mask.png",img)
cv2.destroyAllWindows()


来源:https://stackoverflow.com/questions/45688099/eliminating-interferential-curve-of-text-in-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!