squidpy.im.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 (
Optional
[str
]) – Image layer inimg
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:
’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 (
Optional
[int
]) – Number of chunks fordask
. For automatic chunking, usechunks = 'auto'
.lazy (
bool
) – Whether to lazily compute the result or not. Only used whenchunks != None
.layer_added (
Optional
[str
]) – Layer of new image layer to add intoimg
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
) – IfTrue
, return the result, otherwise save it to the image container.apply_kwargs (
Mapping
[str
,Any
]) – Keyword arguments forsquidpy.im.ImageContainer.apply()
.kwargs (
Any
) – Keyword arguments formethod
.
- Return type:
- Returns:
: If
copy = True
, returns a new container with the processed image in'{layer_added}'
.Otherwise, modifies the
img
with the following key:squidpy.im.ImageContainer
['{layer_added}']
- the processed image.
- Raises:
NotImplementedError – If
method
has not been implemented.