code: def mat2set(A):
      from numpy import take, ravel, nonzero, transpose, newaxis
  
      if len(A.shape) == 1:
          A = A[newaxis, :]
      offsets = nonzero(ravel(A) - limits(A)[0])[0]
      if len(offsets) == 0:
          return ([], [])
      h, w = A.shape
      x = [0, 1]
      x[0] = offsets // w - (h - 1) // 2
      x[1] = offsets % w - (w - 1) // 2
      x = transpose(x)
      return x, take(ravel(A), offsets)
  
file_path: mahotas/mahotas/tests/pymorph_copy.py
imports: import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: mat2set(A) and returns: x,  take, list,  list