2
我一直在认真阅读文档和重读/运行下面的代码,以便准确理解发生了什么。尽管我的知识仍然存在差距。我希望向您提供代码,并提供意见,这些意见表示我希望有些人愿意填补的知识空白。打破numpy代码
因此,这里有我的要求的朋友:
1)帮我填空白我所知
2)解释什么是在非技术和简单的格式怎么回事一步一步来。
import numpy
import scipy.misc
import matplotlib.pyplot
lena = scipy.misc.lena()
''' Generates an artificial range within the framework of the original array (Which is an image)
This artificial range will be paired with another one and used to 'climb'
Through the original array and make changes'''
def get_indices(size):
arr = numpy.arange(size)
#This sets every fourth element to False? How?
return arr % 4 == 0
lena1 = lena.copy()
xindices = get_indices(lena.shape[0])
yindices = get_indices(lena.shape[1])
'''I am unsure of HOW the below code is executing. I know something is being
Set to zero, but what? And how can I verify it?'''
lena[xindices, yindices] = 0
#What does the argument 211 do exactly?
matplotlib.pyplot.subplot(211)
matplotlib.pyplot.imshow(lena1)
matplotlib.pyplot.show()
谢谢配偶!
您是否尝试了解scipy.misc.lena是否返回?你在哪里或为什么卡住了? –
是的,我明白这一点。对我来说,最令人困惑的部分是“lena [xindices,yindices] = 0” –
'a [i,j]'只是对'a [i] [j]'说的一种粗糙的方式,即索引多维数组。 http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html –