資源簡介
基于matlab的圖像匹配,將匹配圖遍歷整個圖像,,并標記出匹配的地方
代碼片段和文件信息
clear;
yuantu=imread(‘C:\Users\FYC\Desktop\10.jpg‘);%加載原圖象
pipeitu=imread(‘C:\Users\FYC\Desktop\1.jpg‘);%加載匹配圖象
yuantu2gray=rgb2gray(yuantu);%將原圖象轉換為灰度圖象
pipeitu2gray=rgb2gray(pipeitu);%將匹配圖象轉換為灰度圖象
%?yuantu=imadd(yuantu80);
[pipei_heightpipei_width]=size(pipeitu2gray)%獲取匹配圖象的大小尺寸,其值為[長,寬]將匹配圖象的長度值賦給pipei_width將匹配圖象的寬度值賦給pipei_lenth
[yuantu_heightyuantu_width]=size(yuantu2gray)%獲取原圖象的大小尺寸,其值為[長,寬]將原圖象的長度值賦給pipei_width將原圖象的寬度值賦給pipei_lenth
imshow(yuantu);
?hold?on;
?k=0;
?tic%toc?tic?獲得程序執(zhí)行時間
for?i=1:yuantu_height-pipei_height%i是高
????for?j=1:yuantu_width-pipei_width%j是寬度,取遍整個圖像
???????temp_picture=imcrop(yuantu2gray[jipipei_width-1pipei_height-1]);
%???????imcrop(‘圖象名‘[x起點,y起點,x寬度,y寬度])?即匹配圖的大小
%????????r=corr2(temp_picturepipeitu2gray);
F=temp_picture;
評論
共有 條評論