first=first(:,1:200,:);
imshow(first)

%

second=second(:,1:200,:);
imshow(second)

%

c = normxcorr2(second(:,:,1),first(:,:,1));
figure
surf(c) 
shading flat

%

[max_c,imax] = max(abs(c(:)));
[ypeak,xpeak] = ind2sub(size(c),imax(1));
corr_offset = [(xpeak-size(second,2)) 
               (ypeak-size(second,1))];

%

offset = corr_offset;
xoffset = offset(1);
yoffset = offset(2);

%

xbegin = round(xoffset + 1);
xend   = round(xoffset + size(second,2));
ybegin = round(yoffset + 1);
yend   = round(yoffset + size(second,1));

%

r_second = uint8(zeros(size(first)));
r_second(ybegin:yend,xbegin:xend,:) = second;

%


imshow(r_second)

imshowpair(first,r_second,"diff")