Operations on volumetric data
The qim3d
library provides a set of methods for different operations on volumes.
qim3d.operations
qim3d.operations.remove_background
remove_background(vol, median_filter_size=2, min_object_radius=3, background='dark', **median_kwargs)
Remove background from a volume using a qim3d filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The volume to remove background from. |
required |
median_filter_size |
int
|
The size of the median filter. Defaults to 2. |
2
|
min_object_radius |
int
|
The radius of the structuring element for the tophat filter. Defaults to 3. |
3
|
background |
'dark' or 'bright
|
The background type. Can be 'dark' or 'bright'. Defaults to 'dark'. |
'dark'
|
**median_kwargs |
Any
|
Additional keyword arguments for the Median filter. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
filtered_vol |
ndarray
|
The volume with background removed. |
Example
Source code in qim3d/operations/_common_operations_methods.py
qim3d.operations.fade_mask
Apply edge fading to a volume.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vol |
ndarray
|
The volume to apply edge fading to. |
required |
decay_rate |
float
|
The decay rate of the fading. Defaults to 10. |
10
|
ratio |
float
|
The ratio of the volume to fade. Defaults to 0.5. |
0.5
|
geometry |
spherical or cylindrical
|
The geometric shape of the fading. Can be 'spherical' or 'cylindrical'. Defaults to 'spherical'. |
'spherical'
|
invert |
bool
|
Flag for inverting the fading. Defaults to False. |
False
|
axis |
int
|
The axis along which to apply the fading. Defaults to 0. |
0
|
**kwargs |
Any
|
Additional keyword arguments for the edge fading. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
faded_vol |
ndarray
|
The volume with edge fading applied. |
Example
Image before edge fading has visible artifacts from the support. Which obscures the object of interest. Afterwards the artifacts are faded out, making the object of interest more visible for visualization purposes.Source code in qim3d/operations/_common_operations_methods.py
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 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 |
|
qim3d.operations.overlay_rgb_images
Overlay an RGB foreground onto an RGB background using alpha blending.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
background |
ndarray
|
The background RGB image. |
required |
foreground |
ndarray
|
The foreground RGB image (usually masks). |
required |
alpha |
float
|
The alpha value for blending. Defaults to 0.5. |
0.5
|
hide_black |
bool
|
If True, black pixels will have alpha value 0, so the black won't be visible. Used for segmentation where we don't care about background. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
composite |
ndarray
|
The composite RGB image with overlaid foreground. |
Raises:
Type | Description |
---|---|
ValueError
|
If input images have different shapes. |
Note
- The function performs alpha blending to overlay the foreground onto the background.
- It ensures that the background and foreground have the same first two dimensions (image size matches).
- It can handle greyscale images, values from 0 to 1, raw values which are negative or bigger than 255.
- It calculates the maximum projection of the foreground and blends them onto the background.