Thinning of an image

14 次查看(过去 30 天)
aswathy nair
aswathy nair 2015-5-11
I was trying to code for thinning an image and to an extent I got an output. But still the final output does have some small unwanted lines emerging from different areas. My next step was to find intersection points. Because of these small lines, I get points which are actually not intersection points. How can I improve my code in order to avoid those lines.
if true
I = imread('img.jpg');
I = rgb2gray(I);
I = uint8(255*mat2gray(I));
I=imresize(I,[128 128]);
I1=edge(I,'canny',0.6);
I2=edge(I,'canny',0.1);
I = imsubtract(I2,I1);
si = imdilate(I,strel('line',3,0));
se = imerode(I,strel('line',3,0));
I = imsubtract(si,se);
si = imdilate(I,strel('disk',1));
se = imerode(I,strel('disk',3));
I = imsubtract(si,se);
I = imfill(I,'holes');
[L num]=bwlabel(I); %%number of connected objects found in binary%%%
A=[];
for i=1:num
a=find(L==i);
A(i)=size(a,1);
end
[b indxA]=max(A);
L2(128,128)=0;
for i=1:num
if A(i)>=0.9*b
L2(find(L==i))=1;
end
end
I = imerode(L2,strel('disk',1));
I = bwmorph(I,'skel',Inf);
[i,j] = ind2sub(size(I),find(bwmorph(bwmorph(I,'thin',Inf),'branchpoint') == 1));
figure,imshow(I); hold on; plot(j,i,'rx');
end
  1 个评论
Salaheddin Hosseinzadeh
I'm interested to find the answer to this problem as well ;)

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by