Eliminating Interferential Curve of Text in Images

2019-08-17 05:59发布

问题:

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()