import numpy as np image = np.array([ [100, 150, 200], [80, 120, 180], [60, 90, 140] ], dtype=np.uint8) print("原图:") print(image) print("-" * 30) image_dark = np.clip(image - 20, 0, 255).astype(np.uint8) print("1. 变暗20后的图像:") print(image_dark) print("-" * 30) image_crop = image_dark[0:2, 0:2] print("2. 裁剪左上角2×2后的图像:") print(image_crop) print("-" * 30) image_flip = np.fliplr(image_crop) print("3. 水平翻转后的最终图像:") print(image_flip) 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("-" * 40) white_count = np.sum(img == 255) black_count = np.sum(img == 0) print(f"1. 白色像素(255)数量:{white_count}") print(f" 黑色像素(0)数量:{black_count}") print("-" * 40) img_flip = np.fliplr(img) print("2. 水平翻转后的图像:") print(img_flip) print("-" * 40) img_rot90 = np.flipud(img.T) print("3. 逆时针旋转90度后的图像:") print(img_rot90)