Removing noisy lines from image - opencv - python
first of all remember that there is no single solution for all kind of noise and all kind of images. that being said i can think of two solution.
first is using Otsu thresholding:

ret,thresh_img = cv2.threshold(img, 0, 255, cv2.THRESH_BINARY_INV|cv2.THRESH_OTSU)


this will try to guess a good threshold for the image being used.

the other solution would be using "close" morphology transform after thresholding. it will first dilate and then erode the image and using a good kernel( it is also called structuring element ) you can remove the line(although you may remove some of the useful pixels too!!)

kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (4,8))
morph_img = cv2.morphologyEx(thresh_img, cv2.MORPH_CLOSE, kernel)




above is the result of using both otsu threshold and morphology close