def erase_specular(image, lower_threshold=0.0, upper_threshold=150.0):
 thresh = cv2.inRange(image, np.asarray(float(lower_threshold)), np.asarray(256.0))
 kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7, 7))
 hi_mask = cv2.dilate(thresh, kernel, iterations=2)
 specular = cv2.inpaint(image, hi_mask, 2, flags=cv2.INPAINT_TELEA)
 return specular

def erase_specular ( image , lower_threshold = 0.0 , upper_threshold = 150.0 ) : thresh = cv2 . inRange ( image , np . asarray ( float ( lower_threshold ) ) , np . asarray ( 256.0 ) ) kernel = cv2 . getStructuringElement ( cv2 . MORPH_ELLIPSE , ( 7 , 7 ) ) hi_mask = cv2 . dilate ( thresh , kernel , iterations = 2 ) specular = cv2 . inpaint ( image , hi_mask , 2 , flags = cv2 . INPAINT_TELEA ) return specular
erase_specular: removes specular reflections within given threshold using a binary mask .