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 |
-
|
| 17 |
|
| 18 |
grey = im.convert('L') # 转成灰度
|
| 19 |
px = grey.load() # 获取灰度数组
|
|
@@ -29,7 +29,7 @@ def imGreyAlpha(im):
|
|
| 29 |
alpha = px[i, j] # 获取灰度作为alpha值
|
| 30 |
draw.point((i, j), fill=(0, 0, 0, 255 - alpha)) # 填充像素点
|
| 31 |
|
| 32 |
-
|
| 33 |
return im2 # 返回图像
|
| 34 |
|
| 35 |
|
|
|
|
| 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() # 获取灰度数组
|
|
|
|
| 29 |
alpha = px[i, j] # 获取灰度作为alpha值
|
| 30 |
draw.point((i, j), fill=(0, 0, 0, 255 - alpha)) # 填充像素点
|
| 31 |
|
| 32 |
+
|
| 33 |
return im2 # 返回图像
|
| 34 |
|
| 35 |
|