欢迎关注微信公众号——计算机视觉:
How to get the skeleton of an object using OPENCV
http://pinkjade8848.spaces.live.com/blog/cns!E4159959CD42C507!195.entry
Skeletonization is a process for reducing foreground regions in a binary image to a skeletal remnant that largely preserves the extent and connectivity of the original region while throwing away most of the original foreground pixels. Generally speaking, there are 2 methods to obtain the skeleton.(I am not sure there are other methods.)
thinning
distance transform
OpenCV doesnot provide functions for skeletonization, but provides some functions on distance transform, so I use distance transform to complete this task.
Distance transform is an operator normally only applied to binary images. The result of the transform is a gray level image that looks similar to the input image, except that the gray level intensities of points inside foreground regions are changed to show the distance to the closest boundary from each point
This figure show the distance transform.
Following steps show how it achieves:
Input: one image
Output: skeleton image
Step1: convert the input image to grey image if the input one is a 3-channel image. convert the grey image to binary image using threshold:
cvThreshold( src, src, 1, 255, CV_THRESH_BINARY );
Step 2: using distance transform functions to get the distance transform images.
cvDistTransform( src_img, dist_img, CV_DIST_L2,3 ,NULL,NULL );
notes : dist_img is a 32 bit float image, so if it is be display by cvShowImage(), we will find that it is same as src_image. It is better to convert 32F image to 8U image (cvConvertScale(dist_img,dist_img_8u,1,0);), and then show it.
Step 3: Take Laplacian (2nd derivative) of the distance transformed image. cvLaplace(dist_img,dist_img_laplac,3);
Step 4: threshold the result of step 3. this is very important. Otherwise , you can not get it. (Till now. I am not sure how to select the threshold. )
It is supposed that the central ridge in the distance transform should be the same as thee medial axis or skeleton.
In order to remove noise, it is suppose to do some morphology before step 1.
相关推荐
基于opencv的骨架提取代码,利用击中不击中变化实现细化操作。
基于OpenCV写的骨架提取算法,算法具体是利用数字图象处理中的一个算法,实现后有很好的 提取效果,但是时间复杂度较大,效率较低
基于opencv2实现的形态学骨架提取,可供初学者参考。
opencv二值化与细化的例子,代码比较规范,可以参考下
基于OpenCV实现图像骨架提取算法,配置环境VS2019+OpenCV4.5.1
利用查表索引法提取并细化骨架,Mat类型实现、iplimage类型实现
我编写的opencv1.0基于vc6.0的二值化代码,非常好用,希望能给大家提供帮助
基于opencv以及kinect的骨架提取和姿势识别代码,C++环境
可以运行的二值化程序,基于opencv。
二值化程序 用opencv完成图像的二值化,一个小程序
基于opencv的图像处理,直方图均衡化处理,增强图像对比度!
改代码主要涉及到灰度图像的分割,包括均值聚类,ostu两个算法,以及图像的边缘提取,和骨架提取,同时涉及到奶牛乳腺面积密度的计算等等。
利用Opencv绘制骨骼,方便不熟悉Direct2D开发的童鞋使用~
opencv函数,自动域值,快速二值化
用QT做界面设计,c++为底层,opencv处理图像二值化的一个小程序
OpenCvSharp 调试图片可视化插件_OpenCvSharp.DebuggerVisualizers_v4.7_VS2022 Mat 图可视化。
先前进行图像二值化处理时都是通过windows.h 中api进行编程,现在用Opencv二值化图像更简单
opencv+java实现灰度化、二值化、轮廓描边、边缘检测源码有注释
vc6.0 基于opencv的直方图均衡化
opencv彩色图像灰度化的问题 opencv彩色图像灰度化的问题