【发布时间】:2017-12-19 06:06:51
【问题描述】:
import numpy as np
import matplotlib.pyplot as plt
files = ### 100 portrait photos
imgs = [ plt.imread( f_i ) for f_i in files ] # We read all file compositions into imgs
data = np.array( imgs ) # Turn everything into np.array format
mean_imgs = np.mean( data, axis= 0) # Takes the mean of the entire data set
plt.imshow( mean_imgs ) # imgs_mean = array of floats
plt.imshow( mean_imgs.astype( np.uint8 ) ) # Cast mean_imgs into type uint
这可能更像是一个计算机视觉问题,无论如何我试图理解 imshow() 一个包含所有浮点数的数组和一个类型为 uint8 的数组之间的区别。有人可以向我解释这两个操作之间的后端发生了什么吗?
请忽略图片中的变量混淆。只需将它们视为具有不同类型的同一个变量。
【问题讨论】:
标签: arrays python-3.x numpy matplotlib computer-vision