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 –