I'm not exactly sure of what you want to compute, but the lines
x=np.histogram(img1,bins=256)
histgray1 =x
and
y=np.histogram(img2,bins=256)
histgray2 =y
seem a bit off given that you are multiplying histgray1[i]*histgray2[i]
for each i
.
The return value of a numpy histogram is hist, bin_edges
so my guess is that you want to change those lines to
histgray1 = np.histogram(img1,bins=256)[0]
and
histgray2 = np.histogram(img2,bins=256)[0]