ImageProcessing.corners_to_roi

giant.image_processing:

static ImageProcessing.corners_to_roi(row_corners, column_corners)[source]

This method provides a convenient way to convert a set of corners to a region of interest that can be passed to find_poi_in_roi() and locate_subpixel_poi_in_roi().

This method finds the minimum and maximum row and column from row_corners and column_corners, respectively, and then makes a call to meshgrid using these bounds, reversing the output so it is row, col instead of col, row.

The results from this function can be used to directly index into an image

>>> import numpy
>>> import giant.image_processing as gimp
>>> im = numpy.random.randn(500, 600)
>>> local_row_corners = [5.5, 3, 6.5, 8.9]
>>> local_column_corners = [4.3, 2.7, 3.3, 7.8]
>>> roi = im[gimp.ImageProcessing.corners_to_roi(local_row_corners, local_column_corners)]
>>> (roi == im[3:10, 2:9]).all()
True
Parameters:
  • row_corners (Iterable) – a list of corner row locations

  • column_corners (Iterable) – a list of corner column locations

Returns:

row, column subscripts into an image as a tuple of ndarrays of type int

Return type:

Tuple[ndarray, ndarray]