Skip to content

Commit 3ca94fa

Browse files
committed
feat: Enhance rolling ball background subtraction with additional options
1 parent 379487b commit 3ca94fa

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/imcflibs/imagej/processing.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,14 @@ def apply_filter(imp, filter_method, filter_radius, do_3d=False):
6666
return imageplus
6767

6868

69-
def apply_rollingball_bg_subtraction(imp, rolling_ball_radius, do_3d=False):
69+
def apply_rollingball_bg_subtraction(
70+
imp,
71+
rolling_ball_radius,
72+
light_background=False,
73+
sliding=False,
74+
disable=False,
75+
do_3d=False,
76+
):
7077
"""Perform background subtraction using a rolling ball method.
7178
7279
Parameters
@@ -75,6 +82,12 @@ def apply_rollingball_bg_subtraction(imp, rolling_ball_radius, do_3d=False):
7582
Input ImagePlus to filter and threshold
7683
rolling_ball_radius : int
7784
Radius of the rolling ball filter to use
85+
light_background : bool, optional
86+
If set to True, will treat the background as light, by default False
87+
sliding : bool, optional
88+
If set to True, will do a sliding window approach, by default False
89+
disable : bool, optional
90+
If set to True, will disable the smoothing, by default False
7891
do_3d : bool, optional
7992
If set to True, will do a 3D filtering, by default False
8093
@@ -85,7 +98,18 @@ def apply_rollingball_bg_subtraction(imp, rolling_ball_radius, do_3d=False):
8598
"""
8699
log.info("Applying rolling ball with radius %d" % rolling_ball_radius)
87100

88-
options = "rolling=" + str(rolling_ball_radius) + " stack" if do_3d else ""
101+
option_parts = ["rolling=" + str(rolling_ball_radius)]
102+
103+
if light_background:
104+
option_parts.append("light")
105+
if sliding:
106+
option_parts.append("sliding")
107+
if disable:
108+
option_parts.append("disable")
109+
if do_3d:
110+
option_parts.append("stack")
111+
112+
options = " ".join(option_parts)
89113

90114
log.debug("Background subtraction options: %s" % options)
91115

0 commit comments

Comments
 (0)