Skip to content
Snippets Groups Projects
Commit 814cb449 authored by Christian Kento Rasmussen's avatar Christian Kento Rasmussen
Browse files

added arguments to remove_background

parent 23e8dfde
No related branches found
No related tags found
1 merge request!683d removal of background
This commit is part of merge request !68. Comments created here will be created in the context of that merge request.
import qim3d.processing.filters as filters
def remove_background(vol, **kwargs):
def remove_background(vol, size=2, radius=3, background="dark", **kwargs):
"""
Remove background from a volume using a median filter followed by a tophat filter.
Args:
vol: The volume to remove background from.
**kwargs: Additional keyword arguments for the tophat filter.
size: The size of the median filter (default: 2).
radius: The radius of the structuring element for the median filter (default: 3).
background: The background type ('dark' or 'bright', default: 'dark').
**kwargs: Additional keyword arguments for the Median filter.
Returns:
vol: The volume with background removed.
"""
# sets the median filter size to 2 if not specified for removing background artifacts
size = kwargs["size"] if "size" in kwargs else 2
# Create a pipeline with a median filter and a tophat filter
pipeline = filters.Pipeline(
filters.Median(size=size),
filters.Tophat(**kwargs)
filters.Median(size=size, **kwargs),
filters.Tophat(radius=radius, background=background),
)
# Apply the pipeline to the volume
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment