From 3a7e22821f7aaa102113ca5a4e7d683eca00913e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=AD=90=E5=B0=8A?= <2509165011@student.example.com> Date: Thu, 16 Apr 2026 16:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yzz.py | 10 ++++++++++ yzz1.py | Bin 0 -> 1024 bytes yzz2.py | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 yzz.py create mode 100644 yzz1.py create mode 100644 yzz2.py diff --git a/yzz.py b/yzz.py new file mode 100644 index 0000000..3a5e2d4 --- /dev/null +++ b/yzz.py @@ -0,0 +1,10 @@ +import numpy as np + +image = np.array([ + [100, 150, 200], + [80, 120, 180], + [60, 90, 140] +], dtype=np.uint8) + +print("原图:") +print(image) \ No newline at end of file diff --git a/yzz1.py b/yzz1.py new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001 diff --git a/yzz2.py b/yzz2.py new file mode 100644 index 0000000..54b2cbe --- /dev/null +++ b/yzz2.py @@ -0,0 +1,23 @@ +import numpy as np + +# 假设这是从图像中提取的2个特征图 +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) + +# 1. 计算欧几里得距离 +euclidean_dist = np.linalg.norm(vector1 - vector2) + +# 2. 计算余弦相似度 +cos_sim = np.dot(vector1, vector2) / (np.linalg.norm(vector1) * np.linalg.norm(vector2)) + +# 输出结果 +print("\n===== 计算结果 =====") +print("欧几里得距离:", euclidean_dist) +print("余弦相似度:", cos_sim) \ No newline at end of file