MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / clear_white

Method clear_white

tools/slider_util.py:84–106  ·  view source on GitHub ↗

Clear whitespace from image, mainly clearing slider whitespace

(img)

Source from the content-addressed store, hash-verified

82
83 @staticmethod
84 def clear_white(img):
85 """Clear whitespace from image, mainly clearing slider whitespace"""
86 img = cv2.imread(img)
87 rows, cols, channel = img.shape
88 min_x = 255
89 min_y = 255
90 max_x = 0
91 max_y = 0
92 for x in range(1, rows):
93 for y in range(1, cols):
94 t = set(img[x, y])
95 if len(t) >= 2:
96 if x <= min_x:
97 min_x = x
98 elif x >= max_x:
99 max_x = x
100
101 if y <= min_y:
102 min_y = y
103 elif y >= max_y:
104 max_y = y
105 img1 = img[min_x:max_x, min_y: max_y]
106 return img1
107
108 def template_match(self, tpl, target):
109 th, tw = tpl.shape[:2]

Callers 1

discernMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected