Skip to content
Snippets Groups Projects
Commit 35e57ef2 authored by fima's avatar fima :beers:
Browse files

Preparation vor release v0.4.2

parent 8dbe4ece
No related branches found
No related tags found
No related merge requests found
docs/assets/screenshots/releases/filters_with_dask.png

78.7 KiB

......@@ -9,6 +9,12 @@ As the library is still in its early development stages, **there may be breaking
And remember to keep your pip installation [up to date](/qim3d/#get-the-latest-version) so that you have the latest features!
### v0.4.2 (30/09/2024)
- Export and import is now possible in the OME-Zarr standard, including multi-scale datasets.
- Filters now have the option to use Dask when available ![Filters with dask](assets/screenshots/releases/filters_with_dask.png)
### v0.4.1 (30/07/2024)
- Fixed issue with example volumes not being loaded
......
......@@ -8,7 +8,7 @@ Documentation available at https://platform.qim.dk/qim3d/
"""
__version__ = "0.4.1"
__version__ = "0.4.2"
import importlib as _importlib
......
......@@ -8,7 +8,7 @@ def remove_background(
median_filter_size: int = 2,
min_object_radius: int = 3,
background: str = "dark",
**median_kwargs
**median_kwargs,
) -> np.ndarray:
"""
Remove background from a volume using a qim3d filters.
......@@ -51,17 +51,22 @@ def remove_background(
# Apply the pipeline to the volume
return pipeline(vol)
def watershed(
bin_vol: np.ndarray
) -> tuple[np.ndarray, int]:
def watershed(bin_vol: np.ndarray, min_distance: int = 5) -> tuple[np.ndarray, int]:
"""
Apply watershed segmentation to a binary volume.
Args:
bin_vol (np.ndarray): Binary volume to segment.
bin_vol (np.ndarray): Binary volume to segment. The input should be a 3D binary image where non-zero elements
represent the objects to be segmented.
min_distance (int): Minimum number of pixels separating peaks in the distance transform. Peaks that are
too close will be merged, affecting the number of segmented objects. Default is 5.
Returns:
tuple[np.ndarray, int]: Labeled volume after segmentation, number of objects found.
tuple[np.ndarray, int]:
- Labeled volume (np.ndarray): A 3D array of the same shape as the input `bin_vol`, where each segmented object
is assigned a unique integer label.
- num_labels (int): The total number of unique objects found in the labeled volume.
Example:
```python
......@@ -90,7 +95,9 @@ def watershed(
distance = scipy.ndimage.distance_transform_edt(bin_vol)
# Find peak coordinates in distance transform
coords = skimage.feature.peak_local_max(distance, labels=bin_vol)
coords = skimage.feature.peak_local_max(
distance, min_distance=min_distance, labels=bin_vol
)
# Create a mask with peak coordinates
mask = np.zeros(distance.shape, dtype=bool)
......@@ -100,7 +107,9 @@ def watershed(
markers, _ = scipy.ndimage.label(mask)
# Apply watershed segmentation
labeled_volume = skimage.segmentation.watershed(-distance, markers=markers, mask=bin_vol)
labeled_volume = skimage.segmentation.watershed(
-distance, markers=markers, mask=bin_vol
)
# Extract number of objects found
num_labels = len(np.unique(labeled_volume)) - 1
......@@ -108,6 +117,7 @@ def watershed(
return labeled_volume, num_labels
def fade_mask(
vol: np.ndarray,
decay_rate: float = 10,
......@@ -147,7 +157,9 @@ def fade_mask(
"""
if 0 > axis or axis >= vol.ndim:
raise ValueError("Axis must be between 0 and the number of dimensions of the volume")
raise ValueError(
"Axis must be between 0 and the number of dimensions of the volume"
)
# Generate the coordinates of each point in the array
shape = vol.shape
......@@ -186,10 +198,9 @@ def fade_mask(
return vol_faded
def overlay_rgb_images(
background: np.ndarray,
foreground: np.ndarray,
alpha: float = 0.5
background: np.ndarray, foreground: np.ndarray, alpha: float = 0.5
) -> np.ndarray:
"""
Overlay an RGB foreground onto an RGB background using alpha blending.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment