完成作业3-1-3

This commit is contained in:
2509165005
2026-04-16 15:55:20 +08:00
parent 0cabd18739
commit ff59b507ba
3 changed files with 78 additions and 0 deletions

30
练习2.py Normal file
View File

@@ -0,0 +1,30 @@
import numpy as np
img = np.array([
[255, 255, 0, 0 ],
[255, 255, 0, 0 ],
[0, 0, 255, 255],
[0, 0, 255, 255]
], dtype=np.uint8)
print("原图:")
print(img)
print()
white_pixels = np.sum(img == 255)
black_pixels = np.sum(img == 0)
print(f"白色像素(255)的数量:{white_pixels}")
print(f"黑色像素(0)的数量:{black_pixels}")
print()
flipped_horizontal = np.fliplr(img)
print("水平翻转后的图像:")
print(flipped_horizontal)
print()
rotated_ccw = np.flipud(img.T)
print("逆时针旋转90度后的图像:")
print(rotated_ccw)