docstr: Test conversion of 2D dense with some more complex shapes to sparse
  
  Make 10 circles that might overlap
docstr_tok: ["Test","conversion","of","2D","dense","with","some","more","complex","shapes","to","sparse","Make","10","circles","that","might","overlap"]
code: def test_01_04_2d_random_dense_to_sparse(self):
      """
      Test conversion of 2D dense with some more complex shapes to sparse
  
      Make 10 circles that might overlap
      """
      r = np.random.RandomState()
      r.seed(201)
      i, j = np.mgrid[0:50, 0:50]
      dense = np.zeros((10, 1, 1, 1, 50, 50), np.uint32)
      for idx in range(10):
          x_loc = r.uniform() * 30 + 10
          y_loc = r.uniform() * 30 + 10
          max_radius = np.min(
              [min(loc - 1, 49 - loc) for loc in (x_loc, y_loc)]
          )
          radius = r.uniform() * (max_radius - 5) + 5
          mask = ((i - y_loc) ** 2 + (j - x_loc) ** 2) <= radius**2
          dense[idx, 0, 0, 0, mask] = idx + 1
  
      indices = np.array(
          [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]
      )
      sparse = lib_seg.convert_dense_to_sparse(dense)
  
      assert np.sum(dense > 0) == len(sparse)
  
      retrieval = dense[
          :,
          0,
          0,
          0,
          sparse[SPARSE_FIELD.y.value],
          sparse[SPARSE_FIELD.x.value],
      ]
      matches = retrieval == sparse[SPARSE_FIELD.label.value][None, :]
      assert np.all(np.sum(matches, 0) == 1)
  
imports: import numpy
  import centrosome.outline
  import cellprofiler_library.functions.segmentation
  from cellprofiler_library.functions.segmentation import SPARSE_FIELD
label_desc: Use image node_id 5 for calling the TestSegmentation obj's underlying member method code with example usage: obj.test_01_04_2d_random_dense_to_sparse() without return types