Using Python, I have to:
Test_Image and Reference_image into 5x5 blocks,
To divide a square image into square blocks (same number of blocks per axis), I used this method (full repository here):
def blockDivide(img, blockNumber):
imgArray = np.array(Image.open(img))
# Define dimension of image
dimension = imgArray.shape[0]
# Set number of slices per axis
axisSlice = int(math.sqrt(blockNumber))
# Size of each block
arraySize = int(dimension / axisSlice)
# Shape of numpy array to be filled
blocksArray = np.zeros((arraySize, arraySize, blockNumber))
# Split the image into vertical blocks
split_a = np.split(imgArray, axisSlice, axis = 0)
# Set counter to zero
counter = 0
for i in range(axisSlice):
for j in range(axisSlice):
# Split vertical blocks into square blocks
split_b = np.split(split_a[i], axisSlice, axis = 1)
# Fill array with blocks
blocksArray[:, :, counter] = split_b[j]
# Increase counter
counter += 1
return blocksArray