import cv2 as cv
import matplotlib.pyplot as plt
import numpy as np
img = cv.imread("../../file/photos/irre.png", )
# 转换成灰度图像
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# 将图像二值化
ret, th = cv.threshold(gray, 127, 255, 0)
contours, hierarchy = cv.findContours(th, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
cnt = contours[0]
# 画出图像轮廓
img = cv.drawContours(img, [cnt], -1
9.2 图像拟合轮廓
最新推荐文章于 2024-07-25 20:42:47 发布