def centre_mass_img(imdct):
    ''' Calculate the centre of mass of an image along each axes (x,y,z),
        separately.
        Arguments:
        imdct - the image dictionary with the image and header data.
        Output the list of the centre of mass for each axis.
    '''
    
    #> initialise centre of mass array
    com = np.zeros(3, dtype=np.float32)
    #> total image sum
    imsum = np.sum(imdct['im'])

    for ind_ax in [-1, -2, -3]:
        #> list of axes
        axs = range(imdct['im'].ndim)
        del axs[ind_ax]
        #> indexed centre of mass
        icom = np.sum( np.sum(imdct['im'], axis=tuple(axs)) \
                * np.arange(imdct['im'].shape[ind_ax]))/imsum
        #> centre of mass in mm
        com[abs(ind_ax)-1] = icom * imdct['hdr']['pixdim'][abs(ind_ax)]

    return com