上传者: 38691641
|
上传时间: 2022-04-11 10:41:05
|
文件大小: 110KB
|
文件类型: PDF
import cv2
import matplotlib.pyplot as plt
img = cv2.imread("macro-photography-of-strawberry-934066.jpg")
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# otsu阈值
(t,thresh) = cv2.threshold(gray_img,0,255,cv2.THRESH_TOZERO_INV+cv2.THRESH_OTSU)
# 三角法阈值:由直方图凹凸性确定的阈值
(t,thresh1) = cv2.threshold(gray_im