sparrow.im.min_max_filtering#
- sparrow.im.min_max_filtering(sdata, img_layer=None, size_min_max_filter=85, chunks=None, output_layer='min_max_filtered', crd=None, to_coordinate_system='global', scale_factors=None, overwrite=False)#
Apply min max filtering to an image in a SpatialData object using dask (using
dask_image.ndfilters.maximum_filteranddask_image.ndfilters.minimum_filter).The size of the filter can be provided either as an integer or a list of integers corresponding to each channel. Compatibility with image layers that have either two or three spatial dimensions.
- Parameters:
sdata (
SpatialData) – Spatial data object containing the images to be processed.img_layer (
Optional[str] (default:None)) – The image layer insdatato run min_max_filtering on. If not provided, the last image layer insdatais used.size_min_max_filter (
int|list[int] (default:85)) – Size of the min_max filter. If provided as a list, the length must match the number of channels.chunks (
Union[str,tuple[int,...],int,None] (default:None)) – Specification for rechunking the data before applying the function.output_layer (
str(default:'min_max_filtered')) – The name of the output layer. Defaults to “min_max_filtered”.crd (
Optional[tuple[int,int,int,int]] (default:None)) – The coordinates specifying the region of the image to be processed. Defines the bounds (x_min, x_max, y_min, y_max).to_coordinate_system (
str(default:'global')) – The coordinate system to which thecrdis specified. Ignored ifcrdis None.scale_factors (
Optional[Sequence[dict[str,int] |int]] (default:None)) – Scale factors to apply for multiscale.overwrite (
bool(default:False)) – If True overwrites the element if it already exists.
- Return type:
SpatialData- Returns:
: The
sdataobject with the min max filtered image added.- Raises:
ValueError – If
size_min_max_filteris a list and its length does not match the number of channels.
Examples
Apply min max filtering with a single size:
>>> sdata = min_max_filtering(sdata, size_min_max_filtering=50)
Apply min max filtering with different sizes for each channel:
>>> sdata = min_max_filtering(sdata, size_min_max_filtering=[30, 50, 70])