Fifth commit

This commit is contained in:
lan daiqing
2022-07-28 21:35:42 +08:00
parent 3d78b6edb3
commit 493dc7062a
10 changed files with 93 additions and 122 deletions

View File

@@ -7,17 +7,13 @@
# 导入库
import os.path
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
# 建立图片读取类
class pictureRead(object):
def __init__(self, filePath):
self.filePath = filePath
# 图片读取
def fileRead(self):
if self.filePath == " ":
@@ -25,8 +21,7 @@ class pictureRead(object):
else:
face = Image.open(self.filePath)
return face
# 图片转矩阵
# 图片数字化
def imageMatrix(self):
im = np.array(self.fileRead())
return im
@@ -53,9 +48,11 @@ class pictureRead(object):
plt.subplot(121)
# 原图片显示
plt.imshow(self.imageMatrix())
plt.title("Original")
plt.subplot(122)
# 灰色图片显示
plt.imshow(self.imageGrey())
plt.title('Gray')
plt.show()
# 图片保存