163
社区成员




任务 1)从以下网站:南通大学[学校掠影](https://www.ntu.edu.cn/77/list.htm)任选一副图片下载,用Python程序显示原始图片。
from PIL import Image
im = Image.open("D:\夜景.jpg")
im.show()
任务 2)将图片变成黑白图片,并用Python程序显示。
from PIL import Image
im = Image.open("D:\夜景.jpg")
im = im.convert("L")
im.show()
任务3)将图片左右翻转,并用Python程序显示。
from PIL import Image
im = Image.open("D:\夜景.jpg")
im = im.transpose(Image.FLIP_LEFT_RIGHT)
im.show()
任务4)将图片上下翻转,并用Python程序显示。
from PIL import Image
im = Image.open("D:\夜景.jpg")
im = im.transpose(Image.FLIP_TOP_BOTTOM)
im.show()
任务5)自己设想一种图片处理任务,描述清楚,并给出实现代码和程序显示图片结果。
import np as np
from PIL import Image
# 加载图像
img = Image.open("D:\夜景.jpg")
img_array = np.array(img)
Image.fromarray(img_array*2).show()