Nov-07-2023, 03:22 PM
The code is like this and below I'm leaving the error I'm getting in Python (3.7.13):
import numpy as np import matplotlib.pyplot as plt # Define the blood test results for four persons person1_results = [80, 90, 100, 110, 120] person2_results = [95, 105, 90, 115, 100] person3_results = [110, 95, 85, 75, 120] person4_results = [75, 80, 85, 90, 95] # Combine the results into a list all_results = [person1_results, person2_results, person3_results, person4_results] # Set image dimensions image_width = len(person1_results) image_height = len(all_results) # Create an array to store pixel values image = np.zeros((image_height, image_width), dtype=np.uint8) # Iterate through each person's results and set pixel values accordingly for i, results in enumerate(all_results): for j, value in enumerate(results): # Map the blood test result to a pixel value (0-255) pixel_value = int(np.interp(value, [min(results), max(results)], [0, 255]) # Set the pixel value in the image image[i][j] = pixel_value # Display the image plt.imshow(image, cmap='gray') plt.title('Blood Test Results') plt.axis('off') plt.show()**THE ERROR I'm GETTING**
Quote: File "C:\Users\Hynek\AppData\Local\Temp\ipykernel_8964\4016005249.py", line 26
image[i][j] = 1
^
SyntaxError: invalid syntax