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...
- Use bwmorph() to get the skeleton.
- Use bwdist() to get the distance from the centerline to the edge.
- 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
版权声明:本文为博主原创文章,转载请附上博文链接!