Skip to content
Snippets Groups Projects

Refactoring v1.0 prep

13 files
+ 36
36
Compare changes
  • Side-by-side
  • Inline

Files

%% Cell type:code id: tags:
``` python
import qim3d
```
%% Cell type:markdown id: tags:
### Blob detection notebook
%% Cell type:markdown id: tags:
This notebook shows how to do **blob detection** in a 3D volume using the `qim3d` library.
Blob detection is done by using the `qim3d.processing.blob_detection` method, which detects blobs by using the Difference of Gaussian (DoG) blob detection method, and returns two arrays:
- `blobs`: The blobs found in the volume stored as `(p, r, c, radius)`
- `binary_volume`: A binary mask of the volume with the blobs marked as `True`
%% Cell type:markdown id: tags:
### **Example 1**: Blob detection in cement volume
%% Cell type:markdown id: tags:
**Applying Gaussian filter to volume**
%% Cell type:code id: tags:
``` python
# Import 3D volume of cement
cement = qim3d.examples.cement_128x128x128
# Visualize slices of the original cement volume
qim3d.viz.slices(cement, n_slices = 5, show = True)
qim3d.viz.slices_grid(cement, n_slices = 5, show = True)
# Apply Gaussian filter to the cement volume
cement_filtered = qim3d.processing.gaussian(cement, sigma = 2)
# Visualize slices of the filtered cement volume
qim3d.viz.slices(cement_filtered)
qim3d.viz.slices_grid(cement_filtered)
```
%% Output
<Figure size 1000x200 with 5 Axes>
%% Cell type:markdown id: tags:
**Detecting blobs in volume**
%% Cell type:code id: tags:
``` python
# Detect blobs, and get binary mask
blobs, mask = qim3d.processing.blob_detection(
cement_filtered,
min_sigma=1,
max_sigma=8,
threshold=0.001,
overlap=0.1,
background="bright"
)
# Number of blobs found
print(f'Number of blobs found in the volume: {len(blobs)} blobs')
```
%% Output
Bright background selected, volume will be inverted.
Number of blobs found in the volume: 1813 blobs
%% Cell type:code id: tags:
``` python
# Visualize blobs on slices of cement volume
qim3d.viz.detection.circles(blobs, cement, alpha = 0.8, show = True, color = 'red')
```
%% Output
interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…
%% Cell type:markdown id: tags:
**Binary mask of detected blobs**
%% Cell type:code id: tags:
``` python
# Visualize binary mask
qim3d.viz.slicer(mask)
```
%% Output
interactive(children=(IntSlider(value=64, description='Slice', max=127), Output()), layout=Layout(align_items=…
Loading