Skip to main content

Stitch a planar set of tiles into a mosaic

Project description

Stitch2D

Some features in this script require OpenCV 3.0 and ImageMagick.

Stitch2D is a Python script that can be used to stitch a two-dimensional grid of tiles into a mosaic. You can install it from the command line using pip:

pip install stitch2d

Overview

Users can set offsets manually (if the offset is regular) or automatically (if OpenCV is installed). If OpenCV is used, tiles that cannot be placed confidently are excluded from the final mosaic. Tiles are not warped in either case.

The options available in this module are fairly basic. For more complex tilesets, consider using the image stitching plugin in Fiji.

Documentation is available at ReadTheDocs.

Using the Command Line Tools

Example tileset for mosaic (18.5 MB; 8 columns, 5x magnification, snaked)

Begin by collecting the tilesets you want to stitch as subdirectories in a single folder. Each subdirectory will be processed using the same parameters, so offsets for the different tilesets should be very similar.

There are three subcommands that can be accessed from the command line: mosaic, organize, and select. In addition to the text below, information about of these commands can be accessed from the command line using -h.

mosaic

Use the mosaic subcommand to stitch together a set of tiles. The resulting mosaic is saved in the parent of the directory containing the source tiles. From the command line:

stitch2d mosaic

That command should be perfectly adequate, but you can also specify arguments to control how your tiles are stitched:

stitch2d mosaic -p tiles -matcher brute-force -scalar 0.5 -threshold 0.7 --equalize_histogram --create_jpeg

Optional arguments include:

  • -path: Specifies to path to the source tiles. This argument works in all subcommands except organize. If no path is specified, you will be prompted to select a directory.

  • –create_jpeg: Specifies whether to create a half-size JPEG derivative of the final mosaic.

  • –manual: Force manual selection of offsets. The script will default to manual matching if OpenCV is not installed.

The following arguments can be used to tweak the behavior of OpenCV:

  • -matcher: Specifies the algorithm used for feature matching. Must be either “brute-force” or “flann”; “brute-force” is the default. Note: The flann matcher has proven unreliable and is currently disabled.

  • -scalar: Specifies the amount by which to resize source tiles before attempting to match features. Must be a decimal between 0 and 1; the default value is 0.5. Smaller values are faster but potentially less accurate. The mosaic itself will be made from the full-sized tiles.

  • -threshold: The threshold for the Lowe test. Must be a decimal between 0 and 1; the default value is 0.7. Lower values give fewer but better matches.

  • –equalize_histogram: Specifies whether to try to equalize histogram in the source image. This can increase contrast and produce better matches, but increases computation time.

More information about these values can be found in the OpenCV-Python tutorials.

select

Use the selector tool to select tiles to exclude from future SEM element mapping. This tool does the following:

  • Creates a points file for use with Noran System Seven. File contains the center point of each tile that was kept from the original grid. The points file has not been tested.

  • Moves excluded tiles to a directory in the source folder. These tiles are automatically reintegrated if the selection script is run again.

  • Produces a list of tiles to skip. The mosaic script uses this list to fill in gaps in the mosaic where the excluded tiles were removed.

  • Produces a screenshot showing the final selection grid.

To use the select script:

stitch2d select

Click the tiles you’d like to remove, or click a darkened tile to reinstate it. As with the mosaic script, the select command accepts an optional path argument using the -p flag.

organize

This command organizes element maps produces by Noran System Seven into element-specific folders suitable for mosaicking. It accepts optional arguments for the source and destination directories:

stitch2d organize /path/to/source /path/to/destination

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stitch2d-0.30.tar.gz (164.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page