Why does the 'skel' function leave gaps in the skeletons produced?
1 次查看(过去 30 天)
显示 更早的评论
Hi there,
I've been trying to create skeleton images, but I am finding that it doesn't work effectively for shapes that aren't thin (for example, I can get insects to work, but I can't with filled shapes.) My other issue is that there are always gaps in the skeleton, but my understanding of skeletons is that the skeleton of a single object should all be joined up.
Below is my code, which is a 3x3 subplot of 3 images, the images in binary and their corresponding skeletons. The jpg files can be replaced with other images, though the threshold may need to change. I've generally used images against white backgrounds.
clear all
close all
clc
s = imread('stickin.jpg');
a = 1;
p = rgb2gray(s);
p = (p<=220) ;
figure(1)
subplot(3,3,1)
colormap(gray)
imagesc(p)
subplot(3,3,4)
bw = bwmorph(p, 'skel', Inf);
colormap(gray)
imagesc(bw)
% Image 2
b = imread('daddy.jpg');
a = 1;
d = rgb2gray(b);
c = (d<=248) ;
subplot(3,3,2)
colormap(gray)
imagesc(c)
subplot(3,3,5)
bw1 = bwmorph(c, 'skel', Inf);
colormap(gray)
imagesc(bw1)
% Image 3
s1 = imread('widow.jpg');
a = 1;
p1 = rgb2gray(s1);
p1 = (p1<=200) ;
subplot(3,3,3)
colormap(gray)
imagesc(p1)
subplot(3,3,6)
bw1 = bwmorph(p1, 'skel', Inf);
colormap(gray)
imagesc(bw1)
% Plot real images
subplot(3,3,7)
imagesc(s)
subplot(3,3,8)
imagesc(b)
subplot(3,3,9)
imagesc(s1)
Any help would be greatly appreciated.
Thanks,
Annie
2 个评论
Nicola Ferrier
2016-1-6
I thought I had this same problem - it appears to be a function of the DISPLAY (different on Windows vs Linux for me). Save the skeleton, use a different image viewer - perhaps the skeleton is fine (as in my case) but the display was the problem. Check on graphics (try using 'opengl hardwarebasic').
Image Analyst
2016-1-6
You mean that even when you zoomed way in, like I suggested in my answer, so that the pixels were hugely magnified, there were gaps that were not gaps when you looked in the variable editor?
回答(1 个)
Image Analyst
2014-10-22
The skeleton doesn't leave gaps but may appear to if it shrunk down your image (subsampled) for display. Examine the image in the variable editor and see if the gaps are really there.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!