Template Matching using Cross Correlation Indepth Intuition
4.7 هزار بار بازدید -
3 سال پیش
-
Code used in this video:clcclear
Code used in this video:
clc
clear all
close all
warning off
a=[1 1 1 1 1 1;
1 20 2 2 2 1;
1 2 3 3 2 1;
1 2 3 3 2 1;
1 2 2 2 2 1;
1 1 1 1 1 1];
w1=[3 3 2;
3 3 2;
2 2 2];
newA = zeros(size(a)+2);
newA(2:end-1,2:end-1)=a;
a=newA;
[row col]=size(a);
a1=zeros(row,col);
for x=2:1:row-1
for y=2:1:col-1
a1(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)+w1(3)*...
a(x-1,y+1)+w1(4)*a(x,y-1)+w1(5)*a(x,y)+w1(6)*...
a(x,y+1)+w1(7)*a(x+1,y-1)+w1(8)*a(x+1,y)+w1(9)*...
a(x+1,y+1);
end
end
aa1=a1(2:end-1,2:end-1);
%Normalised Version
a2=zeros(row,col);
for x=2:1:row-1
for y=2:1:col-1
a2(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)+w1(3)*...
a(x-1,y+1)+w1(4)*a(x,y-1)+w1(5)*a(x,y)+w1(6)*...
a(x,y+1)+w1(7)*a(x+1,y-1)+w1(8)*a(x+1,y)+w1(9)*...
a(x+1,y+1);
values=[a(x-1,y-1) a(x-1,y) a(x-1,y+1) a(x,y-1)...
a(x,y) a(x,y+1) a(x+1,y-1) a(x+1,y) a(x+1,y+1)];
normalisation_value=sqrt(sum(values.^2));
a2(x,y)=a2(x,y)/normalisation_value;
end
end
aa2=a2(2:end-1,2:end-1);
Practical Implementation:
Demo:
Pattern Finding in Images using Cross Correlation
Pattern Finding in Images using Cross...
Detail Explanation:
Pattern Finding in Image using Cross Correlation | MATLAB
Pattern Finding in Image using Cross ...
Learn Complete Machine Learning & Data Science using MATLAB:
Data Science & Machine Learning using...
Learn Digital Signal Processing using MATLAB:
Digital Signal Processing Matlab
Learn Complete Image Processing & Computer Vision using MATLAB:
Digital Image Processing using MATLAB
🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
#DigitalImageProcessing #MATLAB #ComputerVision
clc
clear all
close all
warning off
a=[1 1 1 1 1 1;
1 20 2 2 2 1;
1 2 3 3 2 1;
1 2 3 3 2 1;
1 2 2 2 2 1;
1 1 1 1 1 1];
w1=[3 3 2;
3 3 2;
2 2 2];
newA = zeros(size(a)+2);
newA(2:end-1,2:end-1)=a;
a=newA;
[row col]=size(a);
a1=zeros(row,col);
for x=2:1:row-1
for y=2:1:col-1
a1(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)+w1(3)*...
a(x-1,y+1)+w1(4)*a(x,y-1)+w1(5)*a(x,y)+w1(6)*...
a(x,y+1)+w1(7)*a(x+1,y-1)+w1(8)*a(x+1,y)+w1(9)*...
a(x+1,y+1);
end
end
aa1=a1(2:end-1,2:end-1);
%Normalised Version
a2=zeros(row,col);
for x=2:1:row-1
for y=2:1:col-1
a2(x,y)=w1(1)*a(x-1,y-1)+w1(2)*a(x-1,y)+w1(3)*...
a(x-1,y+1)+w1(4)*a(x,y-1)+w1(5)*a(x,y)+w1(6)*...
a(x,y+1)+w1(7)*a(x+1,y-1)+w1(8)*a(x+1,y)+w1(9)*...
a(x+1,y+1);
values=[a(x-1,y-1) a(x-1,y) a(x-1,y+1) a(x,y-1)...
a(x,y) a(x,y+1) a(x+1,y-1) a(x+1,y) a(x+1,y+1)];
normalisation_value=sqrt(sum(values.^2));
a2(x,y)=a2(x,y)/normalisation_value;
end
end
aa2=a2(2:end-1,2:end-1);
Practical Implementation:
Demo:
Pattern Finding in Images using Cross Correlation
Pattern Finding in Images using Cross...
Detail Explanation:
Pattern Finding in Image using Cross Correlation | MATLAB
Pattern Finding in Image using Cross ...
Learn Complete Machine Learning & Data Science using MATLAB:
Data Science & Machine Learning using...
Learn Digital Signal Processing using MATLAB:
Digital Signal Processing Matlab
Learn Complete Image Processing & Computer Vision using MATLAB:
Digital Image Processing using MATLAB
🙏🙏🙏🙏🙏🙏🙏🙏
YOU JUST NEED TO DO
3 THINGS to support my channel
LIKE
SHARE
&
SUBSCRIBE
TO MY YOUTUBE CHANNEL
#DigitalImageProcessing #MATLAB #ComputerVision
3 سال پیش
در تاریخ 1400/03/16 منتشر شده
است.
4,762
بـار بازدید شده