Filtering data
The qim3d
library provides a set of methods for filtering volumes.
qim3d.filters
qim3d.filters.gaussian
Applies a Gaussian filter to the input volume using scipy.ndimage.gaussian_filter or dask_image.ndfilters.gaussian_filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The input image or volume. |
required |
dask |
bool
|
Whether to use Dask for the Gaussian filter. |
False
|
chunks |
int or tuple or 'auto'
|
Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. |
'auto'
|
*args |
Any
|
Additional positional arguments for the Gaussian filter. |
()
|
**kwargs |
Any
|
Additional keyword arguments for the Gaussian filter. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The filtered image or volume. |
Source code in qim3d/filters/_common_filter_methods.py
qim3d.filters.median
Applies a median filter to the input volume using scipy.ndimage.median_filter or dask_image.ndfilters.median_filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The input image or volume. |
required |
dask |
bool
|
Whether to use Dask for the median filter. |
False
|
chunks |
int or tuple or 'auto'
|
Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. |
'auto'
|
**kwargs |
Any
|
Additional keyword arguments for the median filter. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The filtered image or volume. |
Source code in qim3d/filters/_common_filter_methods.py
qim3d.filters.maximum
Applies a maximum filter to the input volume using scipy.ndimage.maximum_filter or dask_image.ndfilters.maximum_filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The input image or volume. |
required |
dask |
bool
|
Whether to use Dask for the maximum filter. |
False
|
chunks |
int or tuple or 'auto'
|
Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. |
'auto'
|
**kwargs |
Any
|
Additional keyword arguments for the maximum filter. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The filtered image or volume. |
Source code in qim3d/filters/_common_filter_methods.py
qim3d.filters.minimum
Applies a minimum filter to the input volume using scipy.ndimage.minimum_filter or dask_image.ndfilters.minimum_filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The input image or volume. |
required |
dask |
bool
|
Whether to use Dask for the minimum filter. |
False
|
chunks |
int or tuple or 'auto'
|
Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. |
'auto'
|
**kwargs |
Any
|
Additional keyword arguments for the minimum filter. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The filtered image or volume. |
Source code in qim3d/filters/_common_filter_methods.py
qim3d.filters.tophat
Remove background from the volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The volume to remove background from. |
required |
dask |
bool
|
Whether to use Dask for the tophat filter (not supported, will default to SciPy). |
False
|
**kwargs |
Any
|
Additional keyword arguments.
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The volume with background removed. |
Source code in qim3d/filters/_common_filter_methods.py
qim3d.filters.Pipeline
Example
import qim3d
from qim3d.filters import Pipeline, Median, Gaussian, Maximum, Minimum
# Get data
vol = qim3d.examples.fly_150x256x256
# Show original
fig1 = qim3d.viz.slices_grid(vol, num_slices=5, display_figure=True)
# Create filter pipeline
pipeline = Pipeline(
Median(size=5),
Gaussian(sigma=3, dask = True)
)
# Append a third filter to the pipeline
pipeline.append(Maximum(size=3))
# Apply filter pipeline
vol_filtered = pipeline(vol)
# Show filtered
fig2 = qim3d.viz.slices_grid(vol_filtered, num_slices=5, display_figure=True)
Source code in qim3d/filters/_common_filter_methods.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
qim3d.filters.Pipeline.append
Appends a filter to the end of the sequence.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn |
FilterBase
|
An instance of a FilterBase subclass to be appended. |
required |