소스 뷰어
# 화소(행렬 원소) 접근
import numpy as np

# 화소의 반복 접근 비효율 적
def mat_access( mat ): # c, python, Java style
    for i in range( mat.shape[0] ):
        for j in range( mat.shape[1] ):
            k = mat [ i, j ] 
            mat[ i, j ] = k * 2  # 원소 할당
        pass
    pass
pass 

mat = np.arange(10).reshape(2, -1) 

print("원소 처리 전: mat = ", mat, sep="\n")
print("mat.shape = ", mat.shape )
print( "-"*50 )

mat_access(mat) # 2배씩 증가

print("원소 처리 후: mat = ", mat, sep="\n") 
print( "-"*50 ) 
원소 처리 전: mat = 
[[0 1 2 3 4]
 [5 6 7 8 9]]
mat.shape =  (2, 5)
--------------------------------------------------
원소 처리 후: mat = 
[[ 0  2  4  6  8]
 [10 12 14 16 18]]
--------------------------------------------------