2023(春)Python程序设计作业4:
一、实验题目
Numpy 和 Pillow在图像处理中的应用
二、实验目的
1) 掌握Numpy的基本应用
2)掌握 Pillow的简单用法
三、实验任务
任务 1)从以下网站:南通大学[学校掠影](https://www.ntu.edu.cn/77/list.htm)任选一副图片下载,用Python程序显示原始图片。
from PIL import Image
img_path = 'D:/通大夜景.jpg'
img = Image.open(img_path)
img.show()
任务 2)将图片变成黑白图片,并用Python程序显示。
from PIL import Image
img_path = 'D:通大夜景.jpg'
img = Image.open(img_path)
img_bw = img.convert('L')
img_bw.show()
任务3)将图片左右翻转,并用Python程序显示。
from PIL import Image
img_path = 'D:/通大夜景.jpg'
img = Image.open(img_path)
img_lr = img.transpose(Image.FLIP_LEFT_RIGHT)
img_lr.show()
任务4)将图片上下翻转,并用Python程序显示。
from PIL import Image
img_path = 'D:/通大夜景.jpg'
img = Image.open(img_path)
img_ud = img.transpose(Image.FLIP_TOP_BOTTOM)
img_ud.show()
...全文