資源簡介
在matlab平臺上實現基于小波變化的圖像匹配配準,小波變換在圖像匹配領域應用較少,不過它的匹配率高,精度準確效果還是十分明顯的,唯一不足就是匹配時間較長,還有待讀者對之改進~

代碼片段和文件信息
function?testpipei_1()
%使用說明:此函數為單獨使用,不具有交互性,因此必須在E盤下存在名為:P1010813.jpg的圖像,
%在工作區中(此函數所在位置)必須存在名為afterCut.jpg的圖像。afterCut.jpg最好是從
%P1010813.jpg的圖像上剪裁下來的,P1010813.jpg圖像不要太大,最好為500*500以內的,否則
%計算時間會很長
web?-browser?http://www.ilovematlab.cn/thread-10019-1-1.html
yuantu=imread(‘256graycup192.jpg‘);%加載原圖象
pipeitu=imread(‘256graytempcup192.jpg‘);%加載匹配圖象
%subplot(221)imshow(yuantu)
%subplot(222)imshow(pipeitu)
%yuantu2gray=rgb2gray(yuantu);%將原圖象轉換為灰度圖象
%pipeitu2gray=rgb2gray(pipeitu);%將匹配圖象轉換為灰度圖象
yuantu=double(yuantu);
pipeitu=double(pipeitu);
[pipei_heightpipei_width]=size(pipeitu);%獲取匹配圖象的大小尺寸,其值為[長,寬]將匹配圖象的長度值賦給pipei_width將匹配圖象的寬度值賦給pipei_lenth
[yuantu_heightyuantu_width]=size(yuantu);
%wavelet?decomposition
[yuantu_cyuantu_s]=wavedec2(yuantu2‘db1‘);
[pipeitu_cpipeitu_s]=wavedec2(pipeitu2‘db1‘);
yuantu_A1=appcoef2(yuantu_cyuantu_s‘db1‘1);
pipeitu_A1=appcoef2(pipeitu_cpipeitu_s‘db1‘1);
%subplot(221)imshow(uint8(yuantu_A1));
%subplot(222)imshow(uint8(pipeitu_A1));
yuantu_A2=appcoef2(yuantu_cyuantu_s‘db1‘2);
pipeitu_A2=appcoef2(pipeitu_cpipeitu_s‘db1‘2);
%subplot(221)imshow(uint8(yuantu_A2));
%subplot(222)imshow(uint8(pipeitu_A2));
[pipei_height1pipei_width1]=size(pipeitu_A1);%獲取匹配圖象的大小尺寸,其值為[長,寬]將匹配圖象的長度值賦給pipei_width將匹配圖象的寬度值賦給pipei_lenth
[yuantu_height1yuantu_width1]=size(yuantu_A1);
[pipei_height2pipei_width2]=size(pipeitu_A2);%獲取匹配圖象的大小尺寸,其值為[長,寬]將匹配圖象的長度值賦給pipei_width將匹配圖象的寬度值賦給pipei_lenth
[yuantu_height2yuantu_width2]=size(yuantu_A2);
subplot(221)imshow(uint8(yuantu_A2));
hold?on;
tic
for?i=1:yuantu_height2-pipei_height2
??for?j=1:yuantu_width2-pipei_width2
????temp_picture2=imcrop(yuantu_A2[jipipei_width2-1pipei_height2-1]);
??????%剪切圖像
????r=corr2(temp_picture2pipeitu_A2);
????????if?r<0.9
????????????continue;
????????elseif?r>0.9
???????????plot(j:j+pipei_width2i‘r‘);
???????????plot(j:j+pipei_width2i+pipei_height2‘r‘);
???????????plot(ji:i+pipei_height2‘r‘);
???????????plot(j+pipei_width2i:i+pipei_height2‘r‘);
???????end
???end
end
subplot(222)imshow(uint8(yuantu_A1));
hold?on;
for?p=i:yuantu_height1-pipei_height1
?????for?q=j:yuantu_width1-pipei_width1
???????temp_picture1=imcrop(yuantu_A1[qppipei_width1-1pipei_height1-1]);
????????%剪切圖像
????????r=corr2(temp_picture1pipeitu_A1);
??????????if?r<0.9
????????????continue;
????????elseif?r>0.9
????????????plot(q:q+pipei_width1p‘r‘);
????????????plot(q:q+pipei_width1p+pipei_height1‘g‘);
????????????plot(qp:p+pipei_height1‘b‘);
????????????plot(q+pipei_width1p:p+pipei_height1‘r‘);
????????end
????end
end
subplot(223)imshow(uint8(yuantu));
hold?on;
for?u=p:yuantu_height-pipei_height
?????for?v=q:yuantu_width-pipei_width
???????temp_picture=imcrop(yuantu[vupipei_width-1pipei_height-1]);
????????%剪切圖像
????????r=corr2(temp_picturepipeitu);
??????????if?r<0.9
????????????continue;
????????elseif?r>0.9
????????????plot(v:v+pipei_widthu‘r‘);
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3447??2008-05-21?10:29??beifen_pipei_wavelet.m
?????文件????????122??2008-05-14?18:20??Matlab中文論壇--助努力的人完成畢業設計.url
?????文件???????3434??2008-05-15?08:26??使用幫助:新手必看.htm
-----------?---------??----------?-----??----
?????????????????7003????????????????????3
- 上一篇:用MATLAB對兩幅圖片進行圖像匹配的實驗
- 下一篇:陰影去除資源matlab
評論
共有 條評論