From 355fa2370c8c0245a2b88d61d6c30c056f6eec3a Mon Sep 17 00:00:00 2001 From: 2509165028 <2509165028@student.edu.cn> Date: Thu, 16 Apr 2026 16:03:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A3=5F1=5F3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 260416_2509165028.py | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 260416_2509165028.py diff --git a/260416_2509165028.py b/260416_2509165028.py new file mode 100644 index 0000000..5963988 --- /dev/null +++ b/260416_2509165028.py @@ -0,0 +1,48 @@ +import numpy as np + +image=np.array([ + [100,150,200], + [80, 120,180], + [60, 90, 140] +],dtype=np.uint8) +print("原图:") +print(image) +brighter = image-20 +print("变暗20:",brighter) +top_left = image[0:2, 0:2] +print("裁剪左上角:",top_left) +flipped1 = np.fliplr(image) +print("水平翻转:",flipped1) + +img = np.array([ + [255, 255, 0, 0 ], + [255, 255, 0, 0 ], + [0, 0, 255, 255], + [0, 0, 255, 255] +], dtype=np.uint8) +flipped2 = np.fliplr(img) +print("水平翻转:",flipped2) +rotated = np.transpose(img) +flipped3 = np.fliplr(img) +print("旋转90度:",flipped3) + +feature_map1=np.array([[1,0,1],[0,1,0],[1,0,1]]) +feature_map2=np.array([[1,1,1],[1,0,0],[1,0,0]]) +vector1 = feature_map1.flatten() +vector2 = feature_map2.flatten() +print("vector1:",vector1) +print("vector2:",vector2) + +vocab = ["Python", "学习", "数据", "人工智能", "编程"] +doc1 = "Python学习编程" +doc2 = "Python人工智能数据" +def text_to_vector(text, vocab): + words = text.split() + vector = np.zeros(len(vocab)) + for i, word in enumerate(vocab): + vector[i] = words.count(word) + return vector +v1 = text_to_vector(doc1, vocab) +v2 = text_to_vector(doc2, vocab) +print("doc1向量:", v1) +print("doc2向量:", v2) \ No newline at end of file