I've loaded a dataset containing images where each is given as a 64x64 luminosity map. These are stored as a vector having shape (4096, 698). So far I've loaded the images from a matlab file and reshaped the images, but the function I've written to process the images is returning only 64x64 images of dots. I've also tried the approach here, but it returned only images of solid black.
Here is an example of what my function is returning:

Here is an example of what I need to achieve:

My code so far appears below. I'm including the line where I reshape my data set in case that's contributing to the issue. I think the issue is with the application of the colormap, but I'm probably wrong on that. Can anybody help me rethink this approach?
# Reshape - these will be luminosity maps
image_data = q3_data['images'].reshape(-1, 64, 64)
def luminosityToImage(luminosity_maps, output_dir='data/isomap_data', colormap='gray'):
'''
Converts a luminosity map to a PIL image via colormap.
APPLY THIS AFTER RESHAPING IMAGE ROWS.
'''
# Create directory to store images if doesn't already exist
os.makedirs(output_dir, exist_ok=True)
# Define the colormap
cmap = cm.get_cmap(colormap)
# Number of images
num_images = luminosity_maps.shape[0]
# Iterate over the luminosity maps
for index in range(num_images):
# Normalize the luminosity map
normalized_map = luminosity_maps[index] / np.max(luminosity_maps[index])
# Apply the colormap
colored_map = cmap(normalized_map)
# Convert to uint8
colored_map_uint8 = (colored_map * 255).astype(np.uint8)
# Convert to PIL image
im = Image.fromarray(colored_map_uint8, mode='RGBA')
# Save the image
im.save(os.path.join(output_dir, f'image_{index}.png'))