From 86aa7bb7af8df33c1bf687d1c1e21f86a6ac14a5 Mon Sep 17 00:00:00 2001 From: Tim-Oliver Buchholz Date: Tue, 9 Jul 2024 08:33:26 +0200 Subject: [PATCH] Rework blob detection to accept a list of scaling factors. --- src/faim_ipa/detection/blobs.py | 9 ++++----- tests/detection/test_blobs.py | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/faim_ipa/detection/blobs.py b/src/faim_ipa/detection/blobs.py index ae6a36f5..8e451e6e 100644 --- a/src/faim_ipa/detection/blobs.py +++ b/src/faim_ipa/detection/blobs.py @@ -15,7 +15,7 @@ def detect_blobs( axial_sigma: float, lateral_sigma: float, h: int, - n_scale_levels: int, + scale_factors: list[int], overlap: float, background_img: Optional[np.ndarray] = None, ) -> np.ndarray: @@ -36,8 +36,8 @@ def detect_blobs( YX extension of the spots. h : h-maxima threshold. - n_scale_levels : - Number of upscaling rounds. + scale_factors : + List of scaling factors to apply to the sigmas. overlap : A value between 0 and 1. If the fraction of area overlapping for 2 blobs is greater than `overlap` the smaller blob is eliminated. @@ -59,8 +59,7 @@ def detect_blobs( ) sigmas = [ - (axial_sigma * 2**i, lateral_sigma * 2**i, lateral_sigma * 2**i) - for i in range(n_scale_levels) + (axial_sigma * f, lateral_sigma * f, lateral_sigma * f) for f in scale_factors ] scale_cube = np.empty(image.shape + (len(sigmas),), dtype=np.uint8) diff --git a/tests/detection/test_blobs.py b/tests/detection/test_blobs.py index 2870c62f..27589297 100644 --- a/tests/detection/test_blobs.py +++ b/tests/detection/test_blobs.py @@ -44,7 +44,7 @@ def test_detect_blobs(): axial_sigma=2.07, lateral_sigma=0.75, h=200, - n_scale_levels=2, + scale_factors=[1, 2], overlap=0.875, background_img=None, ) @@ -68,7 +68,7 @@ def test_detect_blobs(): axial_sigma=2.07, lateral_sigma=0.75, h=200, - n_scale_levels=2, + scale_factors=[1, 2], overlap=0.875, background_img=estimated_bg, )