嘿嘿,简单改一改

This commit is contained in:
张梦南 2025-05-11 22:23:36 +08:00
parent 00e00121ff
commit f3bb080957
3 changed files with 11 additions and 4 deletions

View File

@ -13,4 +13,4 @@ _, binary_image = cv2.threshold(image, 1, 255, cv2.THRESH_BINARY)
将图像灰度值 > 1的像素变为255白色也就是将抠图后保留的部分完全设为白色。其他区域像素全为0黑色
### 结果展示
原图、抠图后的图片、二值化处理抠图后的图片的图片<br>
![binarization](/result/result_zmn.png#pic_center)
![binarization](/result/result_All.png#pic_center)

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB