简体   繁体   English

Python:索引过多的数组?

[英]Python: Array with too many Indices?

I'm trying to understand the code below and what it does:我试图理解下面的代码及其作用:

im = pilimage.open(img_path)
image_array = np.array(im)
imgstack = image_array[area[0]:area[1],
                       area[2]:area[3], z_stack[0]:z_stack[1]]

I know that it opens up an image and stores it in im and then converts im into an array and stores that in image_array .我知道它会打开一个图像并将其存储在im中,然后将im转换为一个数组并将其存储在image_array中。 What I don't really understand is the last part.我不太明白的是最后一部分。 I don't have that much experience with python syntax so can anyone help me.我对 python 语法没有太多经验,所以任何人都可以帮助我。 Thank you so much!太感谢了!

This is an advanced-ish application of the python slice notation which you can learn about here: Understanding slice notation .这是 python 切片符号的高级应用程序,您可以在此处了解:了解切片符号 There are a couple nuances here though:不过,这里有一些细微差别:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM