Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ def imGreyAlpha(im):
|
|
13 |
if isinstance(im,np.ndarray):
|
14 |
im = Image.fromarray(im)
|
15 |
|
16 |
-
im = ImageOps.invert(im)
|
17 |
|
18 |
grey = im.convert('L') # 转成灰度
|
19 |
px = grey.load() # 获取灰度数组
|
@@ -27,7 +27,10 @@ def imGreyAlpha(im):
|
|
27 |
for i in range(w):
|
28 |
for j in range(h):
|
29 |
alpha = px[i, j] # 获取灰度作为alpha值
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
|
33 |
return im2 # 返回图像
|
|
|
13 |
if isinstance(im,np.ndarray):
|
14 |
im = Image.fromarray(im)
|
15 |
|
16 |
+
# im = ImageOps.invert(im)
|
17 |
|
18 |
grey = im.convert('L') # 转成灰度
|
19 |
px = grey.load() # 获取灰度数组
|
|
|
27 |
for i in range(w):
|
28 |
for j in range(h):
|
29 |
alpha = px[i, j] # 获取灰度作为alpha值
|
30 |
+
if alpha == 0:
|
31 |
+
draw.point((i,j), fill=(0,0,0,0))
|
32 |
+
else:
|
33 |
+
draw.point((i, j), fill=(0, 0, 0, alpha)) # 填充像素点
|
34 |
|
35 |
|
36 |
return im2 # 返回图像
|