22 lines
581 B
Python
22 lines
581 B
Python
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) |