I have a basic level of image processing/matlab. I need to write an m file to complete skeletisation of a binary image of the word "skeleton" in white on a black background. It is to be done without using matlab functions for skeletising. thank you

3 次查看(过去 30 天)
Hi, I have a basic level of image processing/matlab. I need to write an m file to complete skeletisation of a binary image of the word "skeleton" in white on a black background. It is to be done without using matlab functions for skeletising. possibly one that will work on all binary images. Thanks
my code is as follows. I created it using an algorithm found online and adapted it to this:
clear all
I=imread('skeleton.jpg')
I = im2double(I);
I = im2bw(I);
figure, imshow(I);
H = size(I, 1); %height of image
W = size(I, 2); %width of image
for i = 2:H-1
for j = 2:W-1
Neighbour = [I(i-1,j) I(i-1,j+1) I(i,j+1) I(i+1,j+1) I(i+1,j) I(i+1,j-1) I(i,j-1) I(i-1,j-1)];
Surrounds = [I(i-1,j) I(i-1,j+1) I(i,j+1) I(i+1,j+1) I(i+1,j) I(i+1,j-1) I(i,j-1) I(i-1,j-1) I(i-1,j)];
Transition = nnz(diff(Surrounds)==1);
Non_zero = sum(Neighbour(:)==1);
if Transition==1 && (2<=Non_zero<=6) && (I(i-1,j)*I(i,j+1)*I(i+1,j)==0) && (I(i,j+1)*I(i+1,j)*I(i,j-1)==0)
I(i,j)=0;
end
end
end
figure, imshow(I)
  5 个评论
Ralph Dunne
Ralph Dunne 2013-4-18
It is a project that I am completing and as part of the project no functions from matlab for the operation may be used. It must be built by creating my own m file which will complete the skeletising of the image. I am stuck from here I found this algorithm online at the link below under Parallel skeletonization algorithm 1 but I seem to have made a mistake as it does not fully work. It seems quite basic when explained in the article but I seem to have a problem with my coding if you have any ideas to help I would really appreciate it.

请先登录,再进行评论。

回答(1 个)

Thomas
Thomas 2013-4-18
The grassfire transform would be easy to implement: http://en.wikipedia.org/wiki/Grassfire_Transform
Be aware that this algorithm is not exceptionally fast. However, it can be parallelized.
  1 个评论
Ralph Dunne
Ralph Dunne 2013-4-18
thanks, I used the example algorithm found in the grassfire link you answered with. I am finding it hard to implement this algorithm. I am not a great coder. does the grassfire return a distance transfrom? the link below is the result I am trying to complete

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Camera Calibration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by