Fifth commit
This commit is contained in:
@@ -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()
|
||||
|
||||
# 图片保存
|
||||
|
Reference in New Issue
Block a user