给定二进制输入图像,我想从距离变换中提取中心线。我已经取得了一些成果,但是,我想知道是否:
im=im2bw(imread('test.tif'));
figure(1), subplot(3,2,1)
imshow(im,[]);
title('Input Image');
imd=bwdist(~im);
subplot(3,2,2)
imshow(imd,[]);
title('Euclidean Distance Transform');
%imw=watershed(imd);
%imw=imw==0;
log=del2(imd);
subplot(3,2,3)
imshow(log,[]);
title('Laplacian of Gaussian');
imp=bwperim(im);
se=strel('disk',1);
imp=imdilate(imp,se);
subplot(3,2,4)
imshow(imp,[]);
title('Dilated Perimeter');
bin=log < -0.2;
mask=bin-imp;
mask=mask>0;
subplot(3,2,5)
imshow(mask,[]);
title('Binazired mask');
rp = regionprops(mask, 'PixelIdxList', 'Area');
rp = rp(vertcat(rp.Area) > 30);
centerline=zeros(size(im));
centerline(vertcat(rp.PixelIdxList))=1;
centerline=bwmorph(centerline,'thin');
subplot(3,2,6)
imshow(centerline,[]);
title('Final mask');
算法的步骤如下: