simpleBlobDetector
implements a simple algorithm for
extracting blobs an Image
object. A blob is a region in an
image that differs in properties (e.g. brightness, color) from surrounding
regions.
Usage
simpleBlobDetector(
image,
min_threshold = 50,
max_threshold = 220,
threshold_step = 10,
min_repeatability = 2,
min_dist_between_blobs = 10,
filter_by_area = TRUE,
min_area = 25,
max_area = 5000,
filter_by_color = TRUE,
blob_color = 0,
filter_by_circularity = FALSE,
min_circularity = 0.8,
max_circularity = Inf,
filter_by_convexity = TRUE,
min_convexity = 0.95,
max_convexity = Inf,
filter_by_inertia = TRUE,
min_inertia_ratio = 0.1,
max_inertia_ratio = Inf
)
Arguments
- image
An
Image
object.- min_threshold
A numeric value representing the starting thresholding value (see Note; default: 50).
- max_threshold
A numeric value representing the ending thresholding value (see Note; default: 220).
- threshold_step
A numeric value representing the step size to go from
min_threshold
tomax_treshold
(see Note; default: 10).- min_repeatability
A numeric value representing the number of threshold values a blob has to be detected at to be considered stable (see Note; default: 2).
- min_dist_between_blobs
A numeric value representing the minimum distance in pixels between pixel group centers from several binary (thresholded) images above which they are considered as distinct blobs (default: 10).
- filter_by_area
A logical indicating whether blobs should be filtered based on their area in pixels (default: TRUE).
- min_area
A numeric value representing the smallest acceptable area for blobs (in pixels). Blobs smaller than this value are discarded (default: 25).
- max_area
A numeric value representing the largest acceptable area for blobs (in pixels). Blobs larger than this value are discarded. (default: 5000).
- filter_by_color
A logical indicating whether blobs should be filtered based on color (default: TRUE).
- blob_color
An integer between 0 and 255 representing the color of the blobs. 0 will select dark blobs, 255 will select bright blobs (default: 0).
- filter_by_circularity
A logical indicating whether blobs should be filtered based on circularity (default: FALSE).
- min_circularity
A numeric value representing the smallest acceptable circularity for blobs. Blobs with smaller circularity than this value are discarded. (default: 0.8).
- max_circularity
A numeric value representing the largest acceptable circularity for blobs. Blobs with larger circularity than this value are discarded. (default: Inf).
- filter_by_convexity
A logical indicating whether blobs should be filtered based on convexity (default: TRUE).
- min_convexity
A numeric value representing the smallest acceptable convexity for blobs. Blobs with smaller convexity than this value are discarded. (default: 0.95).
- max_convexity
A numeric value representing the largest acceptable convexity for blobs. Blobs with larger convexity than this value are discarded. (default: Inf).
- filter_by_inertia
A logical indicating whether blobs should be filtered based on their inertia ratio (default: TRUE).
- min_inertia_ratio
A numeric value representing the smallest acceptable inertia ratio for blobs. Blobs with smaller ratio than this value are discarded. (default: 0.1).
- max_inertia_ratio
A numeric value representing the largest acceptable inertia ratio for blobs. Blobs with larger ratio than this value are discarded. (default: Inf).
Value
A data frame of class blob
with the following columns:
- "id":
a unique identifier for each blob in the image.
- "x":
the x coordinate of each blob in the image.
- "y":
the y coordinate of each blob in the image.
- "size":
the diameter of the circle containing the blob.
Note
simpleBlobDetector
has the following steps:
The
image
is converted to several binary images, each corresponding to a different threshold starting atmin_threshold
and ending atmax_threshold
, by increment ofthreshold_step
.In each binary image, connected white pixels grouped together and their center of mass is calculated.
Groups of connected white pixels across multiple binary images are merged if their centers are less than
min_dist_between_blobs
pixels apart. These are the blobs.The centers and radii of the blobs are computed and returned.
Author
Simon Garnier, garnier@njit.edu
Examples
dots <- image(system.file("sample_img/dots.jpg", package = "Rvision"))
blobs <- simpleBlobDetector(invert(dots), min_threshold = 25, max_threshold = 220,
filter_by_area = TRUE, min_area = 200, max_area = Inf,
filter_by_color = FALSE)