Simplifying Motion Control

Application Notes

Using Micro-Manager and the ASR Microscope Stage for Image Stitching

In microscopy, a common requirement is to create one image of a large sample area. To preserve the desired amount of detail and resolution, the image must be captured at a particular magnification. With a high magnification, the sample area will sometimes be much larger than the field of view. Capturing multiple images and stitching them together provides the same high resolution and detail while still having the ability to analyze the complete picture.

Image stitching is the process of taking a 2D or 3D array of images and combining them into one large, detailed, and high-resolution image. In addition to microscopy, it is used in applications such as image stabilization, panoramic photography, macro photography, and medical imaging.

There are two parts to image-stitching: capturing the array and combining the images. In order to capture the array, the camera or sample needs to move through a number of viewpoints. For 2D microscopy, this means moving the field of view to a set of XY co-ordinates in a plane. For 3D microscopy, you can capture multiple planes by adjusting the focus. After capturing the array, you can use software to re-assemble the larger image.

A common application of Zaber's motorized stages is to move a sample under a microscope to a set of XY co-ordinates. In this article, we will go through the steps of how to set up a system like this and look at a third-party microscopy software tool (Micro-Manager) that makes the process simple.


In this example, we will use the hardware and software listed below. Other microscope cameras have a similar performance. Please contact Zaber if you are interested in configuring a system for your application.

  • Micro-Manager - an open-source microscopy application developed and maintained by Open Imaging with support for a variety of instruments.
  • Fiji - an open-source platform for biological-image image analysis.


In order to configure the stage and controller, you must first install Micro-Manager, add the hardware, and follow the set-up instructions here. The X-MCB2 controller and ASR microscope stage should be set up as a two-axis XYStage device in Micro-Manager.

While adding the XYStage device in the Hardware Configuration Wizard, look for the OpenCVgrabber device in the Available Devices list and add it as well. OpenCVgrabber uses the open-source OpenCV library of computer vision drivers which supports most USB cameras, including the models from Dino-Lite. The list of installed devices should be similar to Figure 1.

Figure 1: Hardware Configuration Wizard

After successfully configuring the hardware, an image from the microscope should be visible in the ImageJ window.

Next, set the origin of the microscope stage by selecting Tools > Stage Position List > Set Origin. This moves the stage to the 'home' and 'away' limit sensors which establishes a reference for positioning, as well as defining the usable travel range. Figure 2 highlights the Set Origin button and the Create Grid button for the next step.

Figure 2: Calibrating the Microscope Stage

Finally, calibrate the movement of the stage to the microscope field of view by setting the pixel size. Select Tools > Pixel Size Calibration to add a new entry.

To find the right pixel size, select Tools and check the Mouse Moves stage box. In the ImageJ window, ensure that the image is in focus and select the Hand tool. Pick a small, recognizable point on the image, and drag the image across the screen. If the point you grabbed moves less than your mouse cursor, return to the Pixel Size Calibration menu and increase the pixel size. If it moves more, decrease the pixel size. Iterate until the image movement matches the cursor movement.

Repeat this process by creating a new entry in Pixel Size Calibration whenever a different magnification of the microscope is needed.

Capture an Image Array

Now that the devices are configured and calibrated, Micro-Manager can be used to automatically create a grid to capture images in a sequential order that can be stitched together. To create a grid, select Tools > Multi-Dimensional Acquisition. In the window, check the Multiple Position (XY) box and select Edit position list…. Select Create Grid to open the Tile Creator.

This creates a reference grid for Micro-Manager to calculate the field of view that we want in the upper left corner of the stitched images, and the field of view we want in lower right corner. With this information, Micro-Manager will determine how many images must be captured in the array.

Select the Hand tool and align the top left corner of the Snap/Live view with the top left corner of the larger image you want to capture. In the Tile Creator, there will be four Set buttons as shown in Figure 3. Select the top Set button and then the left Set button. Drag the Snap/Live view to show bottom right corner to be captured and press the right and bottom Set buttons.

Figure 3: Creating the Grid

If you need a specific amount of overlap between the images, enter an Overlap value. The units can be in pixels, microns, or % of the image. Having some overlap ensures that no details are missed, and allows blending between images for a smoother transition. However, depending on the pixel size and overlap properties that are set, the original positions (top, right, left, bottom) may be shifted slightly to fit the grid calculated within Micro-Manager.

When you are finished, choose OK in the Tile Creator window and Close in the Stage Position List window. If you'd like to save all of the images, check Save Images and choose a directory to save them in. Finally, when you are ready to capture the images, select Acquire and the stage will start moving to each position in the grid while capturing images.

Stitch Images

While there are many options available for assembling images, we use the stitching plugin available through Fiji that is supported by Micro-Manager and ImageJ. After downloading Fiji from the link in the Equipment section above, you can open it by running the included executable file. Go to Plugins > Stitching > Grid/Collection Stitching. You will be presented with a grid where you can simply select the options that correspond to the order in which the pictures were taken.

Fill in the grid size, tile overlap, directory, and file name information. The optimal settings for tile overlap can be determined by using the same pixel size and overlap settings that were used when creating the grid.

Example Output

As an example, we captured an array of high-resolution images of the Zaber logo on one of our business cards as shown in Figure 4.

Figure 4: Original Card Being Magnified

When the grid was created, it required 3 rows of 4 images to cover the area. The acquired images are shown in Figure 5.

Figure 5: Original Pictures

Finally, Figure 6 shows the high-resolution assembled image from the Fiji stitching plugin.

Figure 6: Zaber Logo Image Stitched

Please email or call 1-888-276-8033 to speak with an applications engineer if you are interested in a custom system.