Finding Intersection Points with Template matching
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi Everyone,
I'm trying to perform template matching to find the all the intersection point on a checkerboard(Black and white only). The image i'm trying to use is: 3cross2.png(background), 10by10.jpg(template);(attachments).
For the background i used the value: Lion
I used the code: (The Problem is i can only get one point, how do i detect all the points)
clc, clear all, close all
% Read Lion
lion = imread('3cross2.png');
lion =rgb2gray(lion);
% imshow(lion); figure()
% Read Template
Template = imread('10by10t.jpg');
template = rgb2gray(Template);
% imshow(template)
[RowLionT, ColLionT] = size(template)
sprintf('The size of letter is %dx%d.',RowLionT,ColLionT)
[RowLion, ColLion] = size(lion)
sprintf('The size of letter is %dx%d.',RowLion,ColLion)
cc=normxcorr2(template,lion);
[val, idx] = max(cc);
[RowCC, ColCC] = size(cc)
sprintf('The size of letter is %dx%d.',RowCC,ColCC)
imshow(cc)
[max_cc,imax] = max(abs(cc(:)));
sprintf('The the highest correlation value is %f.',max_cc)
[ypeak,xpeak] = ind2sub(size(cc),imax(1));
sprintf('the row col coords of the best match in the cross corr matrix are %dx%d.',ypeak,xpeak)
BestRow = ypeak - (RowLionT-1);
BestCol = xpeak - (ColLionT-1);
sprintf('The Row Col coordinates of the best match in orig matrix are %d %d.',BestCol,BestRow)
figure,imshow(lion);
hold on
o = plot((BestCol+((ColLionT-1)/2)), (BestRow+((RowLionT-1)/2)), 'ro', 'MarkerSize', 10);
0 comentarios
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!