def img_to_graph(img, mask=None, return_as=sparse.coo_matrix, dtype=None):
 img = np.atleast_3d(img)
 (n_x, n_y, n_z) = img.shape
 return _to_graph(n_x, n_y, n_z, mask, img, return_as, dtype)

def img_to_graph ( img , mask = None , return_as = sparse . coo_matrix , dtype = None ) : img = np . atleast_3d ( img ) ( n_x , n_y , n_z ) = img . shape return _to_graph ( n_x , n_y , n_z , mask , img , return_as , dtype )
graph of the pixel-to-pixel gradient connections edges are weighted with the gradient values .