在使用imread
读取图像然后使用imresize
之后,我的某些图像最终变成100%紫色,并且实际图像丢失了。
image = imread('../assets/signatures/Alex/train/' + file_name,flatten=True)
image = self.normalize(image)
def normalize(self, image):
image = imresize(image, (128,128))
# Here is where the image turns purple
plt.imshow(image)
plt.show()
image = np.ndarray.flatten(image, order='C')
return image
imresize
这样做有原因吗?也许是尺寸问题?所有图像的起始尺寸都不同。
我还要提及的是,每当生成错误的图像输出时都会引发此错误:
C:\Users\alexh\Anaconda3\envs\Labs_Env\lib\site-packages\scipy\misc\pilutil.py:97: RuntimeWarning: overflow encountered in float_scalars
cscale = cmax ** cmin
C:\Users\alexh\Anaconda3\envs\Labs_Env\lib\site-packages\scipy\misc\pilutil.py:104: RuntimeWarning: overflow encountered in power
bytedata = (data ** cmin) * scale + low
C:\Users\alexh\Anaconda3\envs\Labs_Env\lib\site-packages\scipy\misc\pilutil.py:104: RuntimeWarning: invalid value encountered in multiply
bytedata = (data ** cmin) * scale + low