完成作业3-1-3

This commit is contained in:
2509165016
2026-04-16 15:29:50 +08:00
parent ee6a6f6e9c
commit 64892df511
3 changed files with 26 additions and 0 deletions

26
2509165016--1.py Normal file
View File

@@ -0,0 +1,26 @@
import numpy as np
# 定义3x3灰度图像
image = np.array([
[100, 150, 200],
[80, 120, 180],
[60, 90, 140]
], dtype=np.uint8)
print("原图:")
print(image)
# 1. 变暗20每个像素值减20需确保数值非负uint8会自动截断这里手动保证
image_dark = np.clip(image - 20, 0, 255)
print("\n变暗20后")
print(image_dark)
# 2. 裁剪左上角2x2区域
image_crop = image[:2, :2]
print("\n裁剪左上角2x2区域")
print(image_crop)
# 3. 水平翻转
image_flip = np.fliplr(image)
print("\n水平翻转:")
print(image_flip)