process#
- squidpy.im.process(img, *, layer=None, library_id=None, method='smooth', chunks=None, lazy=False, layer_added=None, channel_dim=None, copy=False, apply_kwargs=mappingproxy({}), **kwargs)[source]#
Process an image by applying a transformation.
- Parameters:
- img
ImageContainer High-resolution image.
- layer
str|None(default:None) Image layer in
imgthat should be processed. If None and only 1 layer is present, it will be selected.- library_id
str|Sequence[str] |None(default:None) Name of the Z-dimension(s) that this function should be applied to. For not specified Z-dimensions, the identity function is applied. If None, all Z-dimensions are processed at once, treating the image as a 3D volume.
- method
Literal['smooth','gray'] |Callable[...,NDArray[Any]] (default:'smooth') Processing method to use. Valid options are:
’smooth’ -
skimage.filters.gaussian().’gray’ -
skimage.color.rgb2gray().
Alternatively, any
callable()can be passed as long as it has the following signature:numpy.ndarray(height, width, channels)->numpy.ndarray(height, width[, channels]).- chunks
int|None(default:None) Number of chunks for Dask. For automatic chunking, use
chunks = 'auto'.- lazy
bool(default:False) Whether to lazily compute the result or not. Only used when
chunks != None.- layer_added
str|None(default:None) Layer of new image layer to add into
imgobject. If None, use'{layer}_{method}'.- channel_dim
str|None(default:None) Name of the channel dimension of the new image layer. Default is the same as the original, if the processing function does not change the number of channels, and
'{channel}_{processing}'otherwise.- copy
bool(default:False) If
True, return the result, otherwise save it to the image container.- apply_kwargs
Mapping[str,Any] (default:mappingproxy({})) Keyword arguments for
squidpy.im.ImageContainer.apply().- kwargs
Any Keyword arguments for
method.
- img
- Returns:
ImageContainer|None– Ifcopy = True, returns a new container with the processed image in'{layer_added}'.Otherwise, modifies the
imgwith the following key:squidpy.im.ImageContainer['{layer_added}']- the processed image.
- Raises:
NotImplementedError – If
methodhas not been implemented.