feat generate 修改中心点判断

This commit is contained in:
zhouchengrong
2024-04-29 11:12:49 +08:00
parent 9d5ef6048c
commit 6843021a45

View File

@@ -167,7 +167,7 @@ def stain_detection(image, spot_size=100):
# 寻找轮廓 # 寻找轮廓
contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
# 过滤非连续的纯白区域 # 过滤非连续的纯白区域
filtered_contours = [cnt for cnt in contours if cv2.contourArea(cnt) >= 30] # 根据面积进行过滤这里假设面积大于30的为连续区域 filtered_contours = [cnt for cnt in contours if cv2.contourArea(cnt) >= 300] # 根据面积进行过滤这里假设面积大于30的为连续区域
# 如果有连续的纯白区域存在 # 如果有连续的纯白区域存在
if filtered_contours: if filtered_contours:
# 将纯白区域替换为灰色 # 将纯白区域替换为灰色