
彩色图像采用OTSU方法和三角阈值进行分割(使用opencv-python)。
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
import cv2
import matplotlib.pyplot as plt
image = cv2.imread(macro-photography-of-strawberry-934066.jpg)
grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 使用 Otsu 阈值方法确定阈值 (t, thresh)
otsu_threshold = cv2.threshold(grayscale_image, 0, 255, cv2.THRESH_TOZERO_INV + cv2.THRESH_OTSU)
# 应用三角法阈值,该阈值基于直方图的凸性进行计算 (t, thresh1)
triangle_threshold = cv2.threshold(grayscale_image, 0, 255, cv2.THRESH_TOZERO_INV | cv2.THRESH_TRIANGLE)
全部评论 (0)
还没有任何评论哟~


