I = imread('after-384x288.jpg'); subplot(2,3,1);imshow(I, []); xlabel('input') C = zeros(256); x = 1 y = 1 nx = 200 ny = 300 xoffset = 20 yoffset = 12 A=I(x:nx-xoffset, y:ny-yoffset); B=I(x+xoffset:nx, y+yoffset:ny); subplot(2,3,2);imshow(A, []); xlabel('A') subplot(2,3,3);imshow(B, []); xlabel('B') i = sub2ind(size(C), double(A(:)+1), double(B(:)+1) ); u = unique(i); C(u) = hist(i, u); subplot(2,3,4); imshow(C,[]); xlabel('C') subplot(2,3,5); imshow(log(C+1),[]); xlabel('log(C+1)') subplot(2,3,6); imshow(C>0,[]); xlabel('C>0')