There seems to be an error in your code, you normalize the histogram by the size of the histogram instead of the size of the image! Otherwise the total probability is != 1
N=256;
h=zeros(N,N);
...
...
[r,c] = size(h); % THIS SHOULD BE size(image_1) !
b= h./(r*c); % normalized joint histogram