Hello,
I'm tying to show the result (five plots for detected patterns) of the code below in one plot but in vain,
any idea please
help is much appreciated
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
Best Answer