资源简介
经典的NCC匹配算法,精度较高,可以精确到亚像素级别
代码片段和文件信息
function [correlate_peakimg peak_coordination] = Matchimg( imgimg0)
%UNtitleD3 Summary of this function goes here
% Detailed explanation goes here
% img : origin image
% img0: template image
%
% tic;
% img=imread(inputargs);
% img0=imread(inputargs0);
% %Convert RGB image to gray image
%
% if size(img3) > 1
% img = rgb2gray(img);
% end
% if size(img03) > 1
% img0 = rgb2gray(img0);
% end
% % t1=isgray(img);
% t2=isgray(img0);
% if ~t1
% img=rgb2gray(img);
% end
% if ~t2
% img0=rgb2gray(img0);
% end
[M N]=size(img);
[M0 N0]=size(img0);
new=rand(M-M0N-N0);
% to calculate the R‘s average
img0=im2double(img0);
i=0;
j=0;
Ssum=0;
for j=1:M0
for i=1:N0
SGrayVlue=img0(ji);
Ssum=Ssum+SGrayVlue;
end
end
Saverage=Ssum/(N0*M0);
% --**
% NCCO
img=im2double(img);
MAX=0;
u=0;
v=0;
for j=1:M-M0
for i=1:N-N0
cropimg=imcrop(img[i j N0-1 M0-1]);
% to calculate the S‘s average
cropimg=im2double(cropimg);
Rsum=0;
for j1=1:M0
for i1=1:N0
RGrayVlue=cropimg(j1i1);
Rsum=Rsum+RGrayVlue;
- 上一篇:自己编写卷积程序 matlab
- 下一篇:MATPOWER中文手册
评论
共有 条评论