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.

  • img (ImageContainer) – High-resolution image.

  • layer (Optional[str]) – Image layer in img that should be processed. If None and only 1 layer is present, it will be selected.

  • library_id (Union[str, Sequence[str], 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 (Union[str, Callable[..., ndarray[Any, dtype[Any]]]]) –

    Processing method to use. Valid options are:

    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 (Optional[int]) – Number of chunks for dask. For automatic chunking, use chunks = 'auto'.

  • lazy (bool) – Whether to lazily compute the result or not. Only used when chunks != None.

  • layer_added (Optional[str]) – Layer of new image layer to add into img object. If None, use '{layer}_{method}'.

  • channel_dim (Optional[str]) – 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) – If True, return the result, otherwise save it to the image container.

  • apply_kwargs (Mapping[str, Any]) – Keyword arguments for squidpy.im.ImageContainer.apply().

  • kwargs (Any) – Keyword arguments for method.

Return type



If copy = True, returns a new container with the processed image in '{layer_added}'.

Otherwise, modifies the img with the following key:


NotImplementedError – If method has not been implemented.