docstr: Fill a labels matrix by labeling each rectangle in the grid
docstr_tok: ["Fill","a","labels","matrix","by","labeling","each","rectangle","in","the","grid"]
code: def fill_grid(self, workspace, gridding):
      """Fill a labels matrix by labeling each rectangle in the grid"""
      assert isinstance(gridding, Grid)
      i, j = numpy.mgrid[
          0 : gridding.image_height, 0 : gridding.image_width
      ]
      i_min = int(
          gridding.y_location_of_lowest_y_spot - gridding.y_spacing / 2
      )
      j_min = int(
          gridding.x_location_of_lowest_x_spot - gridding.x_spacing / 2
      )
      i = numpy.floor((i - i_min) / gridding.y_spacing).astype(int)
      j = numpy.floor((j - j_min) / gridding.x_spacing).astype(int)
      mask = (
          (i >= 0)
          & (j >= 0)
          & (i < gridding.spot_table.shape[0])
          & (j < gridding.spot_table.shape[1])
      )
      labels = numpy.zeros(
          (int(gridding.image_height), int(gridding.image_width)), int
      )
      labels[mask] = gridding.spot_table[i[mask], j[mask]]
      return labels
  
imports: from cellprofiler_core.constants.module import HELP_ON_MEASURING_DISTANCES
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.subscriber import LabelSubscriber, GridSubscriber
  from cellprofiler_core.setting.text import LabelName, Integer
  from cellprofiler_core.utilities.core.module.identify import add_object_location_measurements, add_object_count_measurements, get_object_measurement_columns
  from cellprofiler.modules import _help
  import numpy
  from centrosome.cpmorphology import centers_of_labels
  from cellprofiler_core.utilities.grid import Grid
  from cellprofiler_core.module import Module
  from cellprofiler_core.object import Objects
label_desc: Use image node_id 7 for calling the IdentifyObjectsInGrid obj's underlying member method code with example usage: obj.fill_grid(workspace, gridding) and returns: labels