how to assign a different label the each regions localised between two markers
3 次查看(过去 30 天)
显示 更早的评论
After detecting(marking with markers)classes based on labels below : X=[1 0 1 ; 0 1 0 ; 1 0 1 ;];
Y=[1 0 1 ; 0 1 0 ; 1 0 0 ;];
O=[0 1 0 ; 1 0 1 ; 0 1 0 ;];
-=[0 0 0 ; 1 1 1 ; 0 0 0 ;];
L=[1 0 0 ; 1 0 0 ; 1 1 1 ;];
in order to separate regions using the code below :
t = imread('I.png'); A = squelette(t); B = 2*A - 1 ;
patterns = {[1 0 1; 0 1 0; 1 0 1]; ... % X
[1 0 1; 0 1 0; 1 0 0]; ... % Y
[0 1 0; 1 0 1; 0 1 0]; ... % O
[0 0 0; 1 1 1; 0 0 0]; ... % -
[1 0 0; 1 0 0; 1 1 1] ;} ; % L
labels = {'X', 'Y', 'O', '-', 'L'} ;
matches = cell( size(labels )) ;
for pId = 1 : numel( patterns )
nel = numel( patterns{pId} ) ;
ker = 2*patterns{pId} - 1 ;
[r, c] = find( conv2(B, rot90(rot90(ker)), 'full') == nel ) ;
matches{pId} = [r, c] ;
figure(pId) ; clf ; hold on ;
spy(A) ;
plot( c, r, 'r+', 'MarkerSize', 2 ) ;
title( sprintf( 'Matches for "%s" pattern', labels{pId} )) ;
end
With the function "squelette" Skeletonization using voronoi by Yohai in the link below http://www.mathworks.com/matlabcentral/fileexchange/27543-skeletonization-using-voronoi result in picture:
how to assign a different label the each regions localised between two markers ??
Any idea?
help is much appreciated
0 个评论
采纳的回答
Image Analyst
2014-1-3
Remove the pixels at the marker locations from your binary image, then call bwlabel or bwconncomp.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!