时间:2022-06-08 09:20:08 | 栏目:Python代码 | 点击:次
opencv logo原图 VS 骨架化效果图如下:
# 图像骨架化~ import cv2 import imutils import numpy as np img = np.zeros((390, 390, 3), dtype="uint8") cv2.putText(img, "Beautiful Girl.....", (50, 190), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 3) cv2.imshow("img", img) cv2.waitKey(0) cv2.imwrite("j.jpg", img) # 骨架图依赖灰度图 # 灰度图转换法一 img = cv2.imread('opencv_logo.jpg') # 读取为BGR图 cv2.imshow("origin", img) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # BGR图转换灰度图 # 灰度图转换二 gray = cv2.imread('opencv_logo.jpg', 0) # 直接读取为灰度图 cv2.imshow("gray", gray) # 骨架化图像 skeleton = imutils.skeletonize(gray, size=(3, 3)) cv2.imshow("Skeleton", skeleton) cv2.waitKey(0)
参考: