otsu阈值分割算法python
时间: 2023-09-03 20:16:08 浏览: 183
OTSU阈值分割算法是一种对图像进行二值化的高效算法,由日本学者OTSU于1979年提出。在OpenCV中,可以使用Python来实现OTSU阈值分割算法。以下是一个示例的Python代码:
```python
import cv2
import numpy as np
from matplotlib import pyplot as plt
image = cv2.imread("E:/python/cv/OTSU/test.jpg")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
ret1, th1 = cv2.threshold(gray, 0, 255, cv2.THRESH_OTSU)
plt.subplot(131), plt.imshow(image, "gray")
plt.title("source image"), plt.xticks([]), plt.yticks([])
plt.subplot(132), plt.hist(image.ravel(), 256)
plt.title("Histogram"), plt.xticks([]), plt.yticks([])
plt.subplot(133), plt.imshow(th1, "gray")
plt.title("OTSU,
#### 引用[.reference_title]
- *1* *3* [阈值化分割(二)OTSU法-附Python实现](https://blog.csdn.net/u010128736/article/details/52801310)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [Opencv之Otsu阈值处理(Python)](https://blog.csdn.net/qq_44116998/article/details/124645657)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文