problem in Matching two shifted images

1 view (last 30 days)
mohammad nemat
mohammad nemat on 12 Apr 2021
Commented: mohammad nemat on 12 Apr 2021
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 Comments
DGM
DGM on 12 Apr 2021
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 on 12 Apr 2021
yes. i changed picture you can see result and image it's not clear. do you see any code for shifting image like this?

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!