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