diff --git a/lx1 b/lx1 new file mode 100644 index 0000000..1eb4b98 --- /dev/null +++ b/lx1 @@ -0,0 +1,22 @@ +import numpy as np + +image = np.array([ + [100, 150, 200], + [80, 120, 180], + [60, 90, 140] +], dtype=np.uint8) + +print("原图:") +print(image) + +image_dark = image - 20 +print("变暗20: ") +print(image_dark) + +image_crop = image[0:2, 0:2] +print("裁剪左上角: ") +print(image_crop) + +image_flip = np.fliplr(image) +print("水平翻转: ") +print(image_flip) \ No newline at end of file diff --git a/lx2 b/lx2 new file mode 100644 index 0000000..4a6cfb0 --- /dev/null +++ b/lx2 @@ -0,0 +1,11 @@ +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) + +white_count = np.sum(img == 255) +black_count = np.sum(img == 0)