基于Python的OpenCV骨架化图像并显示(skeletonize)
作者:程序媛一枚~ 时间:2021-04-29 17:56:21
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.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)
参考:
https://www.pyimagesearch.com/2015/02/02/just-open-sourced-personal-imutils-package-series-opencv-convenience-functions/
来源:https://blog.csdn.net/qq_40985985/article/details/118655620
标签:Python,OpenCV,骨架化图像,skeletonize
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python函数式编程实现登录注册功能
2022-02-16 14:03:31
![](https://img.aspxhome.com/file/2023/8/65138_0s.jpg)
浅谈Scrapy网络爬虫框架的工作原理和数据采集
2023-08-24 22:17:21
![](https://img.aspxhome.com/file/2023/0/79700_0s.jpg)
深入分析PHP引用(&)
2023-11-23 00:42:35
![](https://img.aspxhome.com/file/2023/1/55771_0s.jpg)
html+css+js实现别踩白板小游戏
2023-09-02 10:05:42
![](https://img.aspxhome.com/file/2023/4/56064_0s.png)
Python中使用语句导入模块或包的机制研究
2023-02-21 15:06:40
vscode中配置jupyter的详细步骤(彻底解决Failed to start the Kernel问题)
2022-06-21 06:56:26
![](https://img.aspxhome.com/file/2023/0/83870_0s.png)
在阿里云服务器上配置CentOS+Nginx+Python+Flask环境
2023-07-26 09:47:46
python+django+selenium搭建简易自动化测试
2022-01-25 06:17:16
![](https://img.aspxhome.com/file/2023/3/75903_0s.png)
Python字典循环添加一键多值的用法实例
2021-07-15 14:48:48
Python 函数list&read&seek详解
2022-02-14 03:04:21
![](https://img.aspxhome.com/file/2023/7/86447_0s.png)
asp模块化分页源码
2008-04-13 07:02:00
简单实例解释Oracle分页查询
2023-07-16 00:54:03
![](https://img.aspxhome.com/file/2023/0/63730_0s.jpg)
网页设计的十要十不要
2007-12-21 13:01:00
sqlserver 触发器实例代码
2012-01-29 18:30:45
Python Flask框架模板操作实例分析
2022-09-21 02:56:23
![](https://img.aspxhome.com/file/2023/0/84060_0s.png)
python 字典有序并写入json文件过程解析
2021-08-21 21:12:01
![](https://img.aspxhome.com/file/2023/7/101497_0s.png)
python中subplot大小的设置步骤
2021-07-30 08:59:37
![](https://img.aspxhome.com/file/2023/2/67312_0s.png)
OpenCV-Python使用cv2实现傅里叶变换
2023-07-08 05:11:06
![](https://img.aspxhome.com/file/2023/2/76692_0s.png)
详解tensorflow之过拟合问题实战
2022-08-13 00:46:30
![](https://img.aspxhome.com/file/2023/8/83688_0s.png)
详解OpenCV中直方图,掩膜和直方图均衡化的实现
2022-10-30 12:03:33
![](https://img.aspxhome.com/file/2023/8/107558_0s.jpg)