Could someone help me with what I need to change to resolve the index out-of-bounds problem in this code? There are codes before the beginning and later too. Do you think it would be relevant?
print("1. Sum of Squared Differences")
print("2. Correlation Coefficient")
print("3. Normalized Cross-Correlation")
cross_image_type = input("Enter the type of cross image referencing: ")
if (cross_image_type == "1"):
h = len(grey_picture_data[0])
w = len(grey_picture_data[0])
r = np.zeros((h,w))
for k in range(0,h):
for l in range(0,w):
for i in range(0,w):
for j in range(0,h):
r[i][j] += (((grey_picture_data[i+k][j+l]) - (grey_picture_data_2[k][l]))**2)
The output on screen -
Enter the name of a color image: crosswalk.jpg
Enter the name of the color template file: crosswalk_template.jpg
1. Sum of Squared Differences
2. Correlation Coefficient
3. Normalized Cross-Correlation
Enter the type of cross image referencing: 1
Traceback (most recent call last):
File "C:\Program Files\Spyder\pkgs\spyder_kernels\py3compat.py", line 356, in compat_exec
exec(code, globals, locals)
File "d:\purdue\engr 133\proj.py", line 206, in <module>
r[i][j] += (((grey_picture_data[i+k][j+l]) - (grey_picture_data_2[k][l]))**2)
IndexError: index 683 is out of bounds for axis 0 with size 683