![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175743/image.jpeg)
Kindly review my program for block matching ? How do I overcome its constraints?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello all! Below is the code for block matching of two imags al and br(which is a sub-image of al). I divided al into 4 blocks, matched with br and computed SSd. Though the result was quite accurate, I have few questions:
- In this case, my images blocks are divided exactly, what if my block sizes are different
- This is not the most accurate algorithm. Is there any other way to implement "block matching algorithm"?
clear all;
close all;
al = imread('testimage.jpg');
br = uint8(zeros(125, 125, 3));
br(1:126, 1:126,:) = al(80:205, 100:225 , :)
imtool(al); imtool(br);
al= rgb2gray(al);
al = im2double(al);
br= rgb2gray(br);
br = im2double(br);
c(1:126 , 1:126, :) = al(1:126 , 1:126, :)
d(1:126, 1:126,:) = al(100:225, 100:225,:)
e(1:126, 1:126,:) = al(100:225, 1:126,:)
f(1:126, 1:126,:) = al(1:126,100:225, :)
imtool(c); imtool(d); imtool(e); imtool(f)
ssdc= 0; ssde=0; ssdd=0; ssdf=0;
diffc = 0; diffd = 0; diffe=0; difff=0;
for( k = 1:1:126)
for(l = 1:1:126)
diffc = c(k,l) - br(k,l);
ssdc = ssdc+ (diffc*diffc);
diffd = d(k,l) - br(k,l);
ssdd = ssdd+ (diffd*diffd);
diffe = e(k,l) - br(k,l);
ssde = ssde+ (diffe*diffe);
difff = f(k,l) - br(k,l);
ssdf = ssdf+ (difff*difff);
end
end
y = [ssdc ssdd ssde ssdf] ;
min(y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145524/image.bmp)
<<
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145525/image.bmp)
>> The sub-block is the image d, which is a part of image a. I got the minimum cost at d. Kindly help me solve the above problem. Thank you!!
0 件のコメント
回答 (1 件)
Image Analyst
2014 年 9 月 25 日
You can use normalized cross correlation. See demo attached below the image it creates.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175743/image.jpeg)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Biomedical Imaging についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!