基于Python的OpenCV骨架化图像并显示(skeletonize)
1. 效编程客栈果图
自己画一张图,原图 VS 骨架效果图如下:
opencv logo原图 VS 骨架化效果图如下:
2. 源码
# 图像骨架化~ import cv2 import imutils import numpy as np img = np.zeros((390, 390, 3), dtype="uint8") cv2.putText(img, "Beautiful Girl.....", (50, 190), cv2.http://www.cppcns.comFONT_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)
参考:
https://www.pyimagesearch.com/2015/02/02/just-open-souwww.cppcns.comrced-personal-imutils-package-series-opencv-convenience-functions/
以上就是基于python的OpenCV骨架化图像并显示(skeletonize)的详细内容,编程客栈更多关于Python的OpenCV骨架化图像的http://www.cppcns.com资料请关注我们其它相关文章!
精彩评论