ImageSegmenterOut

class giant.image_processing.image_segmenter.ImageSegmenterOut(labeled_image, foreground_image, stats, centroids)[source]

Create new instance of ImageSegmenterOut(labeled_image, foreground_image, stats, centroids)

Parameters:
  • labeled_image (ndarray[tuple[Any, ...], dtype[int32]])

  • foreground_image (ndarray[tuple[Any, ...], dtype[uint8]])

  • stats (ndarray[tuple[Any, ...], dtype[int32]])

  • centroids (ndarray[tuple[Any, ...], dtype[float64]])

labeled_image: ndarray[tuple[Any, ...], dtype[int32]]

An image with labeled foreground objects (>=0) of the same shape as the input and dtype np.int32

foreground_image: ndarray[tuple[Any, ...], dtype[uint8]]

A boolean array the same shape as the input with 0 in the background pixels and 1 in the foreground pixels

stats: ndarray[tuple[Any, ...], dtype[int32]]

The stats vector returned from opencv’s connectectedComponentsWithStats as a nx5 array.

The columns are [left x coordinate, top y coordinate, width, height, area] in pixels.

It is best to access the appropriate column using cv2.CC_STAT_LEFT, cv2.CC_STAT_TOP, cv2.CC_STAT_WIDTH, cv2.CC_STAT_HEIGHT, or cv2.CC_STAT_AREA in case opencv ever changes the order.

Each row corresponds to the object number in the labeled image

centroids: ndarray[tuple[Any, ...], dtype[float64]]

The unweighted centroids of each blob in the image as a nx2 array (x, y) in pixels.