加载中…
个人资料
燕子
燕子
  • 博客等级:
  • 博客积分:0
  • 博客访问:3,110
  • 关注人气:6
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Matlab提取二值图像中心线

(2019-03-12 08:37:28)
分类: matlab
Matlab 提取二值图像中心线 (Matlab extract centreline of binary image)


close all; clear all; clc;

binaryImage = imread('0.png');

% Skeletonize
skeletonizedImage = bwmorph(binaryImage, 'skel', inf);
% distance transform.
Dist_Img = bwdist(~binaryImage);
% multiply
CenLine_Img = Dist_Img .* single(skeletonizedImage);
% binarize
T_level = 0.65;
CenLine_Img = uint8(255*im2bw(CenLine_Img, T_level));

% display
figure(1),
imshow(skeletonizedImage, []);
figure(2),
imshow(Dist_Img, []);
figure(3),
imshow(CenLine_Img);

C = unique(CenLine_Img);



--------------------- 
Polygon width and centerline

i have a .shp polygon with a elongated shape like a snake, with variable width (like a snake that have eat an elephant). I`m trying to obtain the centerlines and the width of the snake polygon at each point in the center line.
Easy. Starting from a binary image...
  1. Use bwmorph() to get the skeleton.
  2. Use bwdist() to get the distance from the centerline to the edge.
  3. Then multiply them to get the centerline where every point on the centerline is the distance to the edge.
--------------------- 
作者:Life_XY 
来源:CSDN 
原文:https://blog.csdn.net/yangyangyang20092010/article/details/51541940 
版权声明:本文为博主原创文章,转载请附上博文链接!

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有