num = generated_images.shape[0] # Number of images created
width = int(math.sqrt(num))
height = int(math.ceil(float(num)/width))
shape = generated_images.shape[2:]
image = np.zeros((height * shape[0], width * shape[1]),
dtype = generated_images.dtype)
for index, img in enumerate(generated_images):
i = int(index / width)
j = index % width
image[i*shape[0]:{i+1} * shape[0],
j * shape[1]:(j+1)*shape[1]] = img[0,:,:]
This is an example that I'm looking at: image[i*shape[0]:{i+1} *shape[0] on the last line
j * shape[1]:(j+1)*shape[1]] = img[0,:,:]
I don't understand this part. Please explain what that means.
If you put specific numbers in to understand it, it makes sense roughly.
num = 4 # Total number of images
width = 2 (sqrt(4) # Some images x-axis
height = 2 # Alreadyㅈ Some on the y-axis
Let's say shape = 5, 5 #.
image = np.zeros (2*5, 2*5) # Small image (2x2)
# a large combined image
#
# ._________._________.
# | | |
# | (0, 0) | (0, 1) |
# | | |
# |_________|_________|
# | | |
# | (1, 0) | (1, 1) |
# | | |
# |_________|_________|
#
#
As the for door rotates, i, j in the for statement becomes (0, 0), (0, 1), (1, 0), (1, 1). This index is intended to copy four images to each part of the entire image, as shown in the figure above.
image[i*shape[0]:{i+1} *shape[0], j *shape[1]:(j+1)*shape[1]] is an array of (i, j) burn image portions of a large image, where
img[0,:] is copied and inserted.
© 2025 OneMinuteCode. All rights reserved.