Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from skimage.transform import resize
- # Matice A
- A = np.array([
- [0, 255],
- [255,100],
- ])
- # Funkce pro vytvoření obrázku z dat
- def create_image(data, column_min_vals, column_max_vals):
- num_rows, num_columns = len(data), len(data[0])
- image = np.zeros((num_rows, num_columns + 1, 3), dtype=np.uint8)
- for i in range(num_rows):
- for j in range(num_columns):
- pixel_value = int(np.interp(data[i][j], [column_min_vals[j], column_max_vals[j]], [0, 255]))
- image[i, j] = np.array([pixel_value] * 3)
- return image
- # Min a max hodnoty sloupců
- column_min_vals = np.min(A, axis=0)
- column_max_vals = np.max(A, axis=0)
- # Vytvoření obrázku
- image = create_image(A, column_min_vals, column_max_vals)
- # Rozšíření obrázku na pevnou velikost pro lepší vizualizaci
- image_resized = resize(image, (100, 100, 3), anti_aliasing=True)
- # Zobrazení obrázku
- plt.imshow(image_resized)
- plt.title("Generated Image from Matrix A")
- plt.axis("off")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement