problem in Matching two shifted images

조회 수: 1 (최근 30일)
mohammad nemat
mohammad nemat 2021년 4월 12일
댓글: mohammad nemat 2021년 4월 12일
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)
  댓글 수: 2
DGM
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?
mohammad nemat
mohammad nemat 2021년 4월 12일
yes. i changed picture you can see result and image it's not clear. do you see any code for shifting image like this?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by