class Blob – Blob object

The blob object is an attrtuple returned by Image.find_blobs(). It has 23 fields accessible as attributes or by index [0..22].

class image.blob

Please call Image.find_blobs() to create this object.

x() int

Returns the blob’s bounding box x coordinate. Index [0].

y() int

Returns the blob’s bounding box y coordinate. Index [1].

w() int

Returns the blob’s bounding box width. Index [2].

h() int

Returns the blob’s bounding box height. Index [3].

cx() int

Returns the centroid x position of the blob (rounded to int). Index [4].

cy() int

Returns the centroid y position of the blob (rounded to int). Index [5].

pixels() int

Returns the number of pixels that are part of this blob. Index [6].

rotation() float

Returns the rotation of the blob in radians. Index [7].

code() int

Returns a 32-bit binary number with a bit set for each color threshold that’s part of this blob. Index [8].

count() int

Returns the number of blobs merged into this blob. Index [9].

perimeter() int

Returns the number of pixels on this blob’s perimeter. Index [10].

roundness() float

Returns a value between 0 and 1 representing how round the blob is. Index [11].

x_hist_bins() List[int]

Returns a list of histogram bin values for the x axis of the blob. Index [12].

y_hist_bins() List[int]

Returns a list of histogram bin values for the y axis of the blob. Index [13].

corners() Tuple[Tuple[int, int], Tuple[int, int], Tuple[int, int], Tuple[int, int]]

Returns a 4-tuple of (x, y) tuples for the 4 corners of the blob in sorted clock-wise order starting from the top left. Index [14].

min_corners() Tuple[Tuple[int, int], Tuple[int, int], Tuple[int, int], Tuple[int, int]]

Returns a 4-tuple of (x, y) tuples for the 4 corners of the minimum area rectangle of the blob. Index [15].

cxf() float

Returns the centroid x position of the blob as a float. Index [16].

cyf() float

Returns the centroid y position of the blob as a float. Index [17].

elongation() float

Returns 1.0 - roundness(); a value between 0 and 1 representing how elongated the blob is. Index [18].

area() int

Returns the area of the bounding box around the blob (w * h). Index [19].

density() float

Returns pixels / area, the ratio of blob pixels to bounding box area. Index [20].

compactness() float

Returns (pixels * 4 * pi) / (perimeter * perimeter). Index [21].

rect() Tuple[int, int, int, int]

Returns a rectangle tuple (x, y, w, h) of the blob’s bounding box for use with other image methods like Image.draw_rectangle(). Index [22].