diff --git a/README.md b/README.md index 385426a..e06a34d 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ _, binary_image = cv2.threshold(image, 1, 255, cv2.THRESH_BINARY) 将图像灰度值 > 1的像素变为255(白色),也就是将抠图后保留的部分完全设为白色。其他区域像素全为0(黑色)。 ### 结果展示 原图、抠图后的图片、二值化处理抠图后的图片的图片
-![binarization](/result/result_zmn.png#pic_center) \ No newline at end of file +![binarization](/result/result_All.png#pic_center) \ No newline at end of file diff --git a/binarization.py b/binarization.py index 4e8ff43..133e244 100644 --- a/binarization.py +++ b/binarization.py @@ -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') diff --git a/result/result_All.png b/result/result_All.png new file mode 100644 index 0000000..c5a251e Binary files /dev/null and b/result/result_All.png differ