Files
task-3-1-3-Matrix-Fundament…/hh.py
2026-04-16 15:56:06 +08:00

22 lines
581 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import numpy as np
# 4x4 灰度图像
image = np.array([
[255, 200, 150, 100],
[180, 140, 110, 80],
[120, 90, 60, 40],
[50, 30, 20, 10]
])
# 3x3 彩色图像RGB三通道
color_image = np.array([
[[255, 0, 0], [0, 255, 0], [0, 0, 255]], # 红、绿、蓝
[[255, 255, 0], [0, 255, 255], [255, 0, 255]], # 黄、青、紫
[[128, 128, 128], [100, 100, 100], [50, 50, 50]] # 灰度
])
# 打印结果,让终端有输出
print("=== 灰度图像数组 ===")
print(image)
print("\n=== 彩色图像数组 ===")
print(color_image)