code: def __voxel_4conectedness(shape):
      
      shape = list(shape)
      while 1 in shape: shape.remove(1) # empty resp. 1-sized dimensions have to be removed (equal to scipy.squeeze on the array)
      return int(round(sum([(dim - 1)/float(dim) for dim in shape]) * scipy.prod(shape)))
docs: Returns the number of edges for the supplied image shape assuming 4-connectedness.
      
      The name of the function has historical reasons. Essentially it returns the number
      of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness,
      etc.
      
      @param shape the shape of the image
      @type shape sequence
      @return the number of edges
      @rtype int