How to divide a skeleton into regions based on labels after detecting them in order to connect these regions to determine all the possible paths to matches extremities ?

1 view (last 30 days)
Is it possible to divide that skeleton below :
to a set of regions 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 ;];
after detecting them using this code :
n = 50 ;
A = double( rand(n, n+1) > 0.5 ) ;
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)), 'same') == nel ) ;
matches{pId} = [r, c] ;
figure(pId) ; clf ; hold on ;
spy(A) ;
plot( c, r, 'r+', 'MarkerSize', 20 ) ;
title( sprintf( 'Matches for "%s" pattern', labels{pId} )) ;
set( gcf, 'Units', 'normalized' ) ;
set( gcf, 'Position', [0 0 0.4 0.7] ) ;
end
in order to connect these regions:
1)for every extremity how to determine all the possible paths to matches extremities
2)for every extremity how to determine the paths which verify a configuration of the set of patterns .
here is the source image to perform tests :
https://plus.google.com/photos/yourphotos?banner=pwa&pid=5951475143755957906&oid=109398178563710623613
Any idea? help is much appreciated

Accepted Answer

Image Analyst
Image Analyst on 29 Nov 2013
Can't you just set your image to 0 (false) at those locations, instead of plotting a marker over them? That would break it apart.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!