def create_croppings(self, numpy_array):
# Jitter the colour channel
numpy_array = self.colour_channel_jitter(numpy_array)
y_dim, x_dim = numpy_array.shape[:2]
# Have the x & y coordinate of the crop
crop_x = random.randrange(x_dim - self.cropSize)
crop_y = random.randrange(y_dim - self.cropSize)
# Select which image ordering we'll use from the maximum hamming set
perm_index = random.randrange(self.numPermutations)
final_crops = np.zeros(
(self.tileSize, self.tileSize, 3, 9), dtype=np.float32)
for row in range(3):
for col in range(3):
x_start = crop_x + col * self.cellSize + \
random.randrange(self.cellSize - self.tileSize)
y_start = crop_y + row * self.cellSize + \
random.randrange(self.cellSize - self.tileSize)
# Put the crop in the list of pieces randomly according to the
# number picked
final_crops[:, :, :, self.maxHammingSet[perm_index, row * 3 + col]
] = numpy_array[y_start:y_start + self.tileSize, x_start:x_start + self.tileSize, :]
return final_crops, perm_index