嘿嘿,简单改一改
This commit is contained in:
parent
00e00121ff
commit
f3bb080957
@ -13,4 +13,4 @@ _, binary_image = cv2.threshold(image, 1, 255, cv2.THRESH_BINARY)
|
||||
将图像灰度值 > 1的像素变为255(白色),也就是将抠图后保留的部分完全设为白色。其他区域像素全为0(黑色)。
|
||||
### 结果展示
|
||||
原图、抠图后的图片、二值化处理抠图后的图片的图片<br>
|
||||

|
||||

|
@ -5,7 +5,7 @@ plt.rcParams['font.sans-serif'] = ['simHei']
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
from rembg import remove
|
||||
|
||||
image_zmn = Image.open("file/zmn.jpg")
|
||||
|
||||
|
||||
# 对图像主题进行抠图处理
|
||||
if __name__=='__main__':
|
||||
@ -31,12 +31,19 @@ _, binary_image = cv2.threshold(image, 1, 255, cv2.THRESH_BINARY)
|
||||
cv2.imwrite("result/result_zmn.png", binary_image)
|
||||
|
||||
# 展示图像
|
||||
plt.subplot(1,2,1)
|
||||
plt.subplot(1,3,1)
|
||||
image_zmn = Image.open("file/zmn.jpg")
|
||||
plt.imshow(image_zmn)
|
||||
plt.title('原图')
|
||||
plt.axis('off')
|
||||
|
||||
plt.subplot(1,2,2)
|
||||
plt.subplot(1,3,2)
|
||||
image_zmn_buckle = Image.open("buckle/zmn.png")
|
||||
plt.imshow(image_zmn_buckle)
|
||||
plt.title('抠图处理')
|
||||
plt.axis('off')
|
||||
|
||||
plt.subplot(1,3,3)
|
||||
plt.imshow(binary_image, cmap='gray')
|
||||
plt.title('二值化处理')
|
||||
plt.axis('off')
|
||||
|
BIN
result/result_All.png
Normal file
BIN
result/result_All.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Loading…
x
Reference in New Issue
Block a user