def scrub(cls, image):
"""
Apply Stroke-Width Transform to image.
:param filepath: relative or absolute filepath to source image
:return: numpy array representing result of transform
"""
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
canny, sobelx, sobely, theta = cls._create_derivative(gray)
swt = cls._swt(theta, canny, sobelx, sobely)
shapes = cls._connect_components(swt)
swts, heights, widths, topleft_pts, images = cls._find_letters(swt, shapes)
if(len(swts)==0):
#didn't find any text, probably a bad face
return None
word_images = cls._find_words(swts, heights, widths, topleft_pts, images)
final_mask = np.zeros(swt.shape)
for word in word_images:
final_mask += word
return final_mask
评论列表
文章目录