From 00e00121ffb32b278187d33d5f0e276ce8eaf363 Mon Sep 17 00:00:00 2001 From: Cx330 <1487537121@qq.com> Date: Sun, 11 May 2025 22:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=98=85=E8=AF=BB=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..385426a --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +#

图像二值化处理

+## 运行库 +cv2、matplotlib、PIL、rembg
+onnxruntime(rembg需要用到此库) +## rembg库 +这个库可以对图像中的主体进行抠图处理,去掉背景仅保留人物/动物等。
+初次运行代码会自动下载v2net.onnx模型文件(必须),模型文件大小为176M。安装这个模型需要进行魔法上网。
+rembg[`仓库`](https://github.com/danielgatis/rembg)地址 +## 二值化处理 +```c +_, 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