TrakEM2, alignment for 1000+ TEM-images (2D dataset)


I want to align/montage about 1000 single TEM-images (dataset 1) and about 4000 single TEM-images (dataset 2), using TrakEM2. These datasets are only montages, no image-stacks (just 2D datasets). The dimensions of a single image is 4084x4084 pixel (I had to crop because there were empty areas with the 4k Eagle CCD camera).
Using my new workstation, I already made very nice and homogeneous datasets, but there are few residual misalignments. I used:

Import: Via the “Layers” window-> import sequence as grid
-> Standard parameters, phase correlation, 20% overlap

Alignment: Least square with translation
-> Standard parameters

Using histogram normalization and equalisation in combination with match intensity, the result was very nice.

Can someone recommend special parameter values to adapt to such big 2D-datasets? Remaining misalignments are mostly (after phase correlation import and least square alignment) shifts between rows of about 50-100 pixel, but not between every row.
I already read several manuals about these parameters, but they seem to be optimized for image stacks (3D datasets) with only a small number of images in each layer…

Best regards,

Hi @CaDi,

Can you upload tow or three image pairs for which the montaging does not work?


Hi Stephan,

small parts of the dataset, that get misaligned after whole-dataset alignment, get well aligned when I process these parts separately.

After the textfile-based import of the 1056 images (33x32), the whole dataset looks very nice. Therefore, I calculated the pixel-coordinates using exel (I had no correct TEM-coordinates), after I measured the overlap (712 pixel) and the rotation (238 pixel in “Y” for each image).

After “least square” alignment (translation with standard parameters), most misalignments of the import are corrected (most time only 50-100 pixel shifts), but several black “holes” appear due to too drastic image shift during alignment. Unfortunately, there are several images without “structure”, e.g. empty areas of connective tissue.

After “phase correlation” alignment (20% overlap with standard parameters), there are three horizontal shifts in the datasets; here, e.g. row 1-14 and 15-22 are well aligned, but row 15 is shifted about 100 pixel to the right. The same between row 22 and 23. Most of the rest of the dataset here was well aligned.

I’ll make some screenshots of my alignments and upload them.

Best regards,


I was able to improve the quality, using many different alignments sequentially. Only a very small amout of alignment-errors remained.
I used the following steps:

  1. Import using calculated coordinates
  2. Phase correlation alignment (20% overlap, std. values)
  3. Least square alignment: translation (std. values)
  4. Least square alignment: rigide (std. values)
  5. Least square alignment: similarity (std. values)

An other least square alignment (affine) destroyed the orientation of the dataset. The remaining alignment errors (after 5)) were only in one small area. After aligning these images separately, they were ok, so I don’t know why they remained in the big dataset.

Best regards,

The alignment issue has been addressed in a private thread. Protocol:

  1. Import from text file.
  2. Click random image > Adjust images > Adjust image filters
    Double click Normalize Local Contrast, edit “stds” to 0.5 (don’t forget to press Enter), Apply To: All images in …
  3. Unselect random image
  4. Align > Montage all images in this layer, change:
    minimum image size: 800 px
    maximum image size: 1200 px
    feature descriptor size: 4
    maximal alignment error: 20 px
    minimal inlier ratio: 0
    minimal number of inliers: 5
    expected transformation: Translation
    desired transformation: Translation
    first two checkboxes checked in the last dialog
  5. If successful, repeat with:
    desired transformation: Affine
    regularize: check
    regularizer: Translation
    lambda: 0.01
  6. Select random image Click random image > Adjust images > Adjust image filters
    Double click Normalize Local Contrast in right field to remove, Apply To: All images in …

Your images have a small lens-distortion, particulary in the periphery that you could fix if you have the chance to acquire a lens-correction mosaic on the same microscope with the same settings (4x4 tiles with ~60% overlap, same sample in textured area, i.e. ideally no erythrocytes). If you cannot do that, your montage will have stitching errors of up to 5px.