python 3.x

I'm working on a small image analysis project. Currently, I'm trying to use the multiprocess functionalities to improve the performance of my code. I have a function that calculates GLCM properties from a set of images.

This is the function

def GLCM_Features_modified(image_window):

grayscale_range=32
x_dimenssion=1024
y_dimenssion=1024
feature_map_horizontal=np.zeros((3,x_dimenssion*y_dimenssion))
feature_map_vertical=np.zeros((3,x_dimenssion*y_dimenssion))
feature_map_diag1=np.zeros((3,x_dimenssion*y_dimenssion))
feature_map_diag2=np.zeros((3,x_dimenssion*y_dimenssion))

for m in range(0,image_window.shape[0]):
    GLCM=greycomatrix(image_window[m,:,:],[1],[0,np.pi/4, np.pi/2, (3*np.pi)/4],grayscale_range,symmetric=True,normed=True)
    contrast=greycoprops(GLCM,'contrast')
    homogeneity=greycoprops(GLCM,'homogeneity')
    correlation=greycoprops(GLCM,'correlation')
    feature_map_horizontal[0,m]=contrast[:,0]
    feature_map_horizontal[1,m]=homogeneity[:,0]
    feature_map_horizontal[2,m]=correlation[:,0]
    feature_map_vertical[0,m]=contrast[:,1]
    feature_map_vertical[1,m]=homogeneity[:,1]
    feature_map_vertical[2,m]=correlation[:,1]
    feature_map_diag1[0,m]=contrast[:,2]
    feature_map_diag1[1,m]=homogeneity[:,2]
    feature_map_diag1[2,m]=correlation[:,2]
    feature_map_diag2[0,m]=contrast[:,3]
    feature_map_diag2[1,m]=homogeneity[:,3]
    feature_map_diag2[2,m]=correlation[:,3]

return feature_map_horizontal   

then I want to call this function in another script using the multiprocessing function pool.map but it shows the following error:

File "/Users/andresricardogonzalezbarrios/anaconda3/lib/python3.6/multiprocessing/pool.py", line 644, in get raise self._value

IndexError: too many indices for array

The argument of my function is a 3D array. I have run the function without using pool.map and it runs ok.

Can anyone please explain what is wrong with my code?

this how I'm trying to use the pool.map function

p=Pool() test_1=p.map(GLCM_Features_modified,GLCM_window)

链接地址: http://www.djcxy.com/p/55294.html

上一篇: 为什么我可以将实例方法传递给multiprocessing.Process,而不是multiprocessing.Pool?

下一篇: python 3.x