From 226bffb7b4f4e20ff3778c7cf2d61e25c492fc6e Mon Sep 17 00:00:00 2001 From: Cx330 <1487537121@qq.com> Date: Mon, 31 Mar 2025 20:49:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=9B=9B=E5=BC=A0=E7=85=A7=E7=89=87?= =?UTF-8?q?=E6=94=BE=E5=9C=A8=E4=B8=80=E4=B8=AA=E7=AA=97=E5=8F=A3=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=85=A7=E7=89=87=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/photo.py b/photo.py index 4089c11..549472f 100644 --- a/photo.py +++ b/photo.py @@ -1,3 +1,5 @@ +import matplotlib.pyplot as plt +plt.rcParams['font.sans-serif'] = ['simHei'] from PIL import Image # 读取 128x128 的图片 @@ -9,14 +11,33 @@ image_nearest = image.resize((512, 512), Image.NEAREST) # 最近邻插值 image_linear = image.resize((512, 512), Image.BILINEAR) # 双线性插值 image_cubic = image.resize((512, 512), Image.BICUBIC) # 立方插值 +""" # 保存为指定文件名 image.save("photo/原图.png") image_nearest.save("photo/最近邻插值.png") image_linear.save("photo/双线性插值.png") image_cubic.save("photo/立方插值.png") +""" -# 打开保存的图片 -Image.open("photo/原图.png").show() -Image.open("photo/最近邻插值.png").show() -Image.open("photo/双线性插值.png").show() -Image.open("photo/立方插值.png").show() +plt.subplot(2,2,1) +plt.imshow(image) +plt.title('原图') +plt.axis('off') + +plt.subplot(2,2,2) +plt.imshow(image_nearest) +plt.title('最近邻插值') +plt.axis('off') + +plt.subplot(2,2,3) +plt.imshow(image_linear) +plt.title('双线性插值') +plt.axis('off') + +plt.subplot(2,2,4) +plt.imshow(image_cubic) +plt.title('立方插值') +plt.axis('off') + +plt.tight_layout() +plt.show() \ No newline at end of file