I have two 8 bit grayscale images which are 166 by 256 pixels in dimension. I computed the joint histogram between them and found a few interesting clusters for which I want to map back the values in image space to locate where this corresponds. So for two images A and B (to which the values have already been accessed via numpy arrays)
import numpy as np
import matplotlib.pyplot as plt
rows, cols = A.shape[0], B.shape[1]
N = 256 # bins
#### Numpy's method
#H,xedge,yedge = np.histogram2d(A, B, bins=(N,N))
#### Manually
H1 = np.zeros((N, N), dtype=float)
Hindex = []
IMGindex = []
for i,j in product(range(rows), range(cols)):
H1[A[i,j], B[i,j]] = H1[A[i,j], B[i,j]] + 1
IMGindex.append((i,j))
Hindex.append((A[i,j], B[i,j]))
img = plt.imshow(H1.T, origin='low', interpolation='nearest')
img.set_cmap('hot')
plt.colorbar()
plt.show(img)
Now let's say this produces the following figure: There's something going on in the region where x is between 0 and ~45 and where y is between 0 and ~2-3. This may be kind of a spacey question, but how do I map back those values in the original images using the IMGindex and Hindex arrays I stored?? Or am I approaching the "back-mapping" problem all wrong?