Files
zjsh_yolov11/guanghuaban/guanghua.py
琉璃月光 df7c0730f5 bushu
2025-10-21 14:11:52 +08:00

28 lines
672 B
Python

import cv2
import numpy as np
# 加载图像
img = cv2.imread('1.jpg', cv2.IMREAD_GRAYSCALE)
'''
height, width = img.shape
start_row = height // 7 * 4 # 从 2/3 处开始,到底部
img = img[start_row:, :] # 所有列,只取底部 1/3 行
print(f"✅ 裁剪出底部 1/3 区域,尺寸: {img.shape}")
'''
# ✅ 3. 提取最下方三分之一的区域
# 高斯模糊去除噪声
blurred = cv2.GaussianBlur(img, (5, 5), 0)
# 边缘检测
edges = cv2.Canny(blurred, 50, 150)
# 显示结果
cv2.imshow("Edges", edges)
cv2.waitKey(0)
cv2.destroyAllWindows()
# 接下来可以根据需要进一步处理边缘信息,比如计算裂缝长度、宽度等参数。