[英]Subtract 2D array from each pixel of a 3D image and get a 4D array
[英]Calculating 3D pixel variance from 4D array
假设存在由k个3D图像[x,y,z]组成的4D数组[x,y,z,k]。 有什么方法可以计算4D阵列中3D中每个像素的方差?
例如,我有一个10x10x10x5的数组,想返回一个10x10x10的方差数组; 计算沿k的每个像素(或像素)的方差
如果这没有道理,请告诉我,我会尽力解释。
目前,我的代码是:
tensors = []
while error > threshold:
for _ in range(5): #arbitrary
new_tensor = foo(bar) #always returns array of same size
tensors.append(new_tensor)
tensors = np.stack(tensors, axis = 3)
#tensors.shape
我想计算张量的方差数组
如果您使用的是numpy,则有一种简单的方法:
variance = tensors.var(axis=3)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.