problem in Matching two shifted images
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, i write this code for compute shift between to picture and match to picture for increase quality. i have error when i want to run shifting in two end for please help for this problem.
im = imread("000010.jpg");
im = im2double(im);
im2 = imread("000019.jpg");
im2 = im2double(im2);
p1 = im(150:200 , 280:330);
big_alpa = 0;
ii=0;
jj=0;
for i = 10:665
for j = 50:900
p2 = im2(i:i+50 , j:j+50);
s=0;
a=0;
b=0;
for k = 1:50
for h = 1:50
s = s + (p1(k,h) * p2(k,h));
a = a + (p1(k,h) * p1(k,h));
b = b + (p2(k,h) * p2(k,h));
end
end
alpa = ((s*s) / (a * b));
if(alpa > big_alpa)
big_alpa = alpa;
ii =i;
jj =j;
end
end
end
new1 = ones(740 , 1300 );
for i = 5:715
for j =5:1275
new1(i,j) = (im(i,j) + im2(i+150-ii , j + 280-jj))/2;
end
end
imshow(new1)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/580437/image.jpeg)
댓글 수: 2
DGM
2021년 4월 12일
Well, since I have no idea how big the images are, I'm just going to assume that
k-(150-ii)
and maybe even
l-(280-jj)
are less than one, kind of like what the error suggests.
Errors like this are what happen when you presume image geometry instead of using size() and checking that your indices don't exceed the array boundaries.
Also, is it just me, or is the code you posted not even the code that is giving you the error?
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!