MCPcopy Index your code
hub / github.com/pyload/pyload / substract_bg

Method substract_bg

module/plugins/captcha/LinksaveIn.py:94–114  ·  view source on GitHub ↗
(self, bgpath)

Source from the content-addressed store, hash-verified

92 return bg
93
94 def substract_bg(self, bgpath):
95 bg = Image.open(bgpath)
96 img = self.img.convert("P")
97
98 bglut = bg.resize((256, 1))
99 bglut.putdata(range(256))
100 bglut = list(bglut.convert("RGB").getdata())
101
102 lut = img.resize((256, 1))
103 lut.putdata(range(256))
104 lut = list(lut.convert("RGB").getdata())
105
106 bgpix = bg.load()
107 pix = img.load()
108 orgpix = self.img.load()
109 for x in range(bg.size[0]):
110 for y in range(bg.size[1]):
111 rgb_bg = bglut[bgpix[x, y]]
112 rgb_c = lut[pix[x, y]]
113 if rgb_c == rgb_bg:
114 orgpix[x, y] = (255, 255, 255)
115
116 def eval_black_white(self):
117 new = Image.new("RGB", (140, 75))

Callers 1

recognizeMethod · 0.95

Calls 2

openMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected