<jupyter_start><jupyter_text>Convert to grayscale====================This example shows how to use squidpy.im.process to convert an imagelayer to grayscale.You can convert any layer of squidpy.im.ImageContainer to grayscale. Weuse the argument `method="gray"` to convert the image. This callsskimage.color.rgb2gray in the background.<jupyter_code>import squidpy as sq

import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>First, we load an H&E stained tissue image. Here, we only load a croppeddataset to speed things up. In general, squidpy.im.process can alsoprocess very large images (seesphx\_glr\_auto\_examples\_image\_compute\_process\_hires.py).<jupyter_code>img = sq.datasets.visium_hne_image_crop()<jupyter_output><empty_output><jupyter_text>Then, we convert the image to grayscale and plot the result. With theargument `layer` we can select the image layer that should be processed.When converting to grayscale, the channel dimensions change from 3 to 1.By default, the name of the resulting channel dimension will be`'{{original_channel_name}}_gray'`. Use the argument `channel_dim` toset a new channel name explicitly. By default, the resulting image issaved in the layer `image_gray`. This behavior can be changed with thearguments `copy` and `layer_added`.<jupyter_code>sq.im.process(img, layer="image", method="gray")

fig, axes = plt.subplots(1, 2)
img.show("image", ax=axes[0])
_ = axes[0].set_title("original")
img.show("image_gray", cmap="gray", ax=axes[1])
_ = axes[1].set_title("grayscale")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10933503836317135, 'fraction_numerical': 0.005754475703324808, 'mean_word_length': 6.634146341463414, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '498423', 'license': 'MIT', 'n_tokens_mistral': 502, 'n_tokens_neox': 483, 'n_words': 157, 'path': 'docs/source/auto_examples/image/compute_gray.ipynb', 'repo_name': 'softbear/squidpy_notebooks', 'size': '1564'}