<commit_before>Tutorial
========

Basic Example
-------------

To begin, you need an image that you want to mosaic-ify. You can load it like
so:

.. code-block:: python

    from skimage.io import imread
    img = imread('filepath')

Alternatively, you can use one of the built-in example images provided by
scikit-image library. We'll go with cat picture.

.. code-block:: python

    # Load a sample image
    from skimage import data
    img = data.chelsea()  # cat picture!

Next, you need large collection of images to fill in the tiles in the mosaic.
If you don't have a large collection of images handy, you can generate a
collection of solid-color squares. Real photos are more interesting, but
solid-color squares are nice for experimentation.

.. code-block:: python

    import photomosaic as pm

    # Generate dummy images covering the color gamut to use as a pool.
    pm.generate_tile_pool('pool')

    # Build the pool (analyze the images).
    pool = pm.make_pool('pool/*.png')

Now we have everything we need to make a mosaic. Specify the target image
(``img``), the pool of available tile images (``pool``), and the number of
tiles to divide the image into.

.. code-block:: python

    # Create a mosiac with 15x15 tiles.
    mos = pm.basic_mosaic(img, pool, (15, 15))

Now ``mos`` is our mosaic. We can save it

.. code-block:: python

    from skimage import imsave
    imsave(mos, 'mosaic.png')

or plot it using matplotlib.

.. code-block:: python

    import matplotlib.pyplot as plt<commit_msg>DOC: Tweak wording.<commit_after>Tutorial
========

Basic Example
-------------

To begin, you need an image that you want to mosaic-ify. You can load it like
so:

.. code-block:: python

    from skimage.io import imread
    img = imread('filepath')

Alternatively, you can use one of the built-in example images provided by
scikit-image library. We'll go with cat picture.

.. code-block:: python

    # Load a sample image
    from skimage import data
    img = data.chelsea()  # cat picture!

Next, you need large collection of images to fill in the tiles in the mosaic.
If you don't have a large collection of images handy, you can generate a
collection of solid-color squares. Real photos are more interesting, but
solid-color squares are nice for experimentation.

.. code-block:: python

    import photomosaic as pm

    # Generate a collection of solid-color square images.
    pm.generate_tile_pool('pool/')

    # Analyze the collection (the "pool") of images.
    pool = pm.make_pool('pool/*.png')

Now we have everything we need to make a mosaic. Specify the target image
(``img``), the pool of available tile images (``pool``), and the number of
tiles to divide the image into.

.. code-block:: python

    # Create a mosiac with 15x15 tiles.
    mos = pm.basic_mosaic(img, pool, (15, 15))

Now ``mos`` is our mosaic. We can save it

.. code-block:: python

    from skimage import imsave
    imsave(mos, 'mosaic.png')

or plot it using matplotlib.

.. code-block:: python

    import matplotlib.pyplot as plt
{'fraction_non_alphanumeric': 0.09789750328515112, 'fraction_numerical': 0.005256241787122208, 'mean_word_length': 3.1942148760330578, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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}}
{'dir': 'git-commits-cleaned', 'id': '2847076', 'n_tokens_mistral': 942, 'n_tokens_neox': 872, 'n_words': 409}