[英]How do you reshape numpy array when the resulting 2 dimensions are unknown?
[英]How do you access the Z axis in Tiff's when they are converted to a numpy array? The shape is only in 2 dimensions
当您将Tiff转换为Numpy数组时,我无法访问或控制Z轴。 任何帮助表示赞赏。
编辑:添加代码
img = Image.open("annotation_50.tif")
imgarray = np.array(img)
print imgarray.shape()
结果为(160,228),x和y值准确,但z轴值未显示。 我期望(168,228,264),因为tiff中有264张图像,使其成为3D阵列。
好吧,没有看到您的任何代码,我不知道您在做什么,但是这里有一个建议:
from PIL import Image
import numpy as np
img = Image.open('multi-tiff.tiff') #multi-tiff.tiff is your image
individual_imgs = np.zeros(len_Z,len_Y,len_X) #input the proper size
for i in range(len_of_multi-tiff.tiff): #put in the length of the tiff stack
individual_img[i,:,:] = img.seek(i)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.