Detection in volumetric data
The qim3d library provides a set of detection methods for volumes.
qim3d.detection.blobs
blobs(
volume,
background='dark',
min_sigma=1,
max_sigma=50,
sigma_ratio=1.6,
threshold=0.5,
overlap=0.5,
threshold_rel=None,
exclude_border=False,
)
Detects spherical objects (blobs) in a 3D volume using the Difference of Gaussian (DoG) method.
This function is essential for particle analysis, cell counting, or void detection. It identifies local maxima in the scale-space of the image to locate blobs of various sizes. In addition to returning the precise coordinates and radii of the detected features, it generates a binary mask where the spherical regions are fully reconstructed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
ndarray
|
The 3D input volume. |
required |
background
|
str
|
The intensity of the background relative to the objects.
|
'dark'
|
min_sigma
|
float
|
The minimum standard deviation for the Gaussian kernel. Controls the smallest blob size to detect. Defaults to 1. |
1
|
max_sigma
|
float
|
The maximum standard deviation for the Gaussian kernel. Controls the largest blob size to detect. Defaults to 50. |
50
|
sigma_ratio
|
float
|
The ratio between the standard deviations of consecutive Gaussian kernels in the scale space. Defaults to 1.6. |
1.6
|
threshold
|
float
|
The absolute lower bound for intensity. reduce this value to detect fainter blobs. Defaults to 0.5. |
0.5
|
overlap
|
float
|
The maximum fraction of spatial overlap allowed between two blobs. If two blobs overlap by more than this fraction, the smaller one is eliminated. Defaults to 0.5. |
0.5
|
threshold_rel
|
float or None
|
Minimum intensity of peaks, calculated as |
None
|
exclude_border
|
bool
|
If |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
results |
tuple[ndarray, ndarray]
|
A tuple containing the detection metrics and the resulting segmentation.
|
Example
import qim3d
import qim3d.detection
# Get data
vol = qim3d.examples.cement_128x128x128
vol_blurred = qim3d.filters.gaussian(vol, sigma=2)
# Detect blobs, and get binary_volume
blobs, binary_volume = qim3d.detection.blobs(
vol_blurred,
min_sigma=1,
max_sigma=8,
threshold=0.001,
overlap=0.1,
background="bright"
)
# Visualize detected blobs
qim3d.viz.circles(blobs, vol, alpha=0.8, color='blue')
Source code in qim3d/detection/_common_detection_methods.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |