ini.trakem2.imaging
Class StitchingTEM

java.lang.Object
  extended by ini.trakem2.imaging.StitchingTEM

public class StitchingTEM
extends java.lang.Object

Given: - list of images - grid width - known percent overlap This class will attempt to find the optimal montage, by applying phase-correlation, and/or cross-correlation, and/or SIFT-based correlation) between neighboring images. The method is oriented to images acquired with Transmission Electron Microscopy, where the acquisition of each image elastically deforms the sample, and thus earlier images are regarded as better than later ones. It is assumed that images were acquired from 0 to n, as in the grid.


Nested Class Summary
static class StitchingTEM.PhaseCorrelationParam
          Phase correlation parameters class
 
Field Summary
static float DEFAULT_MIN_R
           
static int DONE
           
static int ERROR
           
static int INTERRUPTED
           
static int LEFT_RIGHT
           
static int SUCCESS
           
static int TOP_BOTTOM
           
static int WORKING
           
 
Constructor Summary
StitchingTEM()
           
 
Method Summary
static double[] correlate(Patch base, Patch moving, float percent_overlap, float scale, int direction, double default_dx, double default_dy, float min_R)
           
static ij.process.ImageProcessor makeStripe(Patch p, ij.gui.Roi roi, float scale)
           
static ij.process.ImageProcessor makeStripe(Patch p, ij.gui.Roi roi, float scale, boolean ignore_patch_transform)
           
static Bureaucrat montageWithPhaseCorrelation(java.util.Collection<Patch> col)
          For each Patch, find who overlaps with it and perform a phase correlation or cross-correlation with it; then consider all successful correlations as links and run the optimizer on it all.
static void montageWithPhaseCorrelation(java.util.Collection<Patch> col, StitchingTEM.PhaseCorrelationParam param)
          Perform montage based on phase correlation
static Bureaucrat montageWithPhaseCorrelation(java.util.List<Layer> layers)
           
static void optimizeTileConfiguration(java.util.ArrayList<AbstractAffineTile2D<?>> tiles, java.util.ArrayList<AbstractAffineTile2D<?>> fixed_tiles, StitchingTEM.PhaseCorrelationParam param)
          Optimize tile configuration by removing bad matches
static java.lang.Runnable stitch(Patch[] patch, int grid_width, double default_bottom_top_overlap, double default_left_right_overlap, boolean optimize, StitchingTEM.PhaseCorrelationParam param)
          Returns the same Patch instances with their coordinates modified; the top-left image is assumed to be the first one, and thus serves as reference; so, after the first image, coordinates are ignored for each specific Patch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKING

public static final int WORKING
See Also:
Constant Field Values

DONE

public static final int DONE
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

INTERRUPTED

public static final int INTERRUPTED
See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values

TOP_BOTTOM

public static final int TOP_BOTTOM
See Also:
Constant Field Values

LEFT_RIGHT

public static final int LEFT_RIGHT
See Also:
Constant Field Values

DEFAULT_MIN_R

public static final float DEFAULT_MIN_R
See Also:
Constant Field Values
Constructor Detail

StitchingTEM

public StitchingTEM()
Method Detail

stitch

public static java.lang.Runnable stitch(Patch[] patch,
                                        int grid_width,
                                        double default_bottom_top_overlap,
                                        double default_left_right_overlap,
                                        boolean optimize,
                                        StitchingTEM.PhaseCorrelationParam param)
Returns the same Patch instances with their coordinates modified; the top-left image is assumed to be the first one, and thus serves as reference; so, after the first image, coordinates are ignored for each specific Patch. The cross-correlation is done always with the image to the left, and on its absence, with the image above. If the cross-correlation returns values that would mean a depart larger than the known percent overlap, the image will be cross-correlated with its second option (i.e. the one above in almost all cases). In the absence of a second option to compare with, the percent overlap is applied as the least damaging option in the montage. The Patch[] array is unidimensional to allow for missing images in the last row not to interfere. The stitching runs in a separate thread; interested parties can query the status of the processing by calling the method getStatus(). The scale is used to make the images smaller when doing cross-correlation. If larger than 1, it gets put back to 1. Rotation of the images is NOT considered by the TOP_LEFT_RULE (phase- and cross-correlation), but it can be for the FREE_RULE (SIFT).

Returns:
A new Runnable task, or null if the initialization didn't pass the tests (all tiles have to have the same dimensions, for example).

makeStripe

public static ij.process.ImageProcessor makeStripe(Patch p,
                                                   ij.gui.Roi roi,
                                                   float scale)

makeStripe

public static ij.process.ImageProcessor makeStripe(Patch p,
                                                   ij.gui.Roi roi,
                                                   float scale,
                                                   boolean ignore_patch_transform)
Parameters:
ignore_patch_transform - will prevent resizing of the ImageProcessor in the event of the Patch having a transform different than identity.
Returns:
FloatProcessor.

correlate

public static double[] correlate(Patch base,
                                 Patch moving,
                                 float percent_overlap,
                                 float scale,
                                 int direction,
                                 double default_dx,
                                 double default_dy,
                                 float min_R)
Parameters:
scale - For optimizing the speed of phase- and cross-correlation.
percent_overlap - The minimum chunk of adjacent images to compare with, will automatically and gradually increase to 100% if no good matches are found.
Returns:
a double[4] array containing:
- x2: relative X position of the second Patch
- y2: relative Y position of the second Patch
- flag: ERROR or SUCCESS
- R: cross-correlation coefficient

montageWithPhaseCorrelation

public static Bureaucrat montageWithPhaseCorrelation(java.util.Collection<Patch> col)
For each Patch, find who overlaps with it and perform a phase correlation or cross-correlation with it; then consider all successful correlations as links and run the optimizer on it all. ASSUMES the patches have only TRANSLATION in their affine transforms--will warn you about it.


montageWithPhaseCorrelation

public static Bureaucrat montageWithPhaseCorrelation(java.util.List<Layer> layers)

montageWithPhaseCorrelation

public static void montageWithPhaseCorrelation(java.util.Collection<Patch> col,
                                               StitchingTEM.PhaseCorrelationParam param)
Perform montage based on phase correlation

Parameters:
col - collection of patches
param - phase correlation parameters

optimizeTileConfiguration

public static void optimizeTileConfiguration(java.util.ArrayList<AbstractAffineTile2D<?>> tiles,
                                             java.util.ArrayList<AbstractAffineTile2D<?>> fixed_tiles,
                                             StitchingTEM.PhaseCorrelationParam param)
Optimize tile configuration by removing bad matches

Parameters:
tiles - complete list of tiles
fixed_tiles - list of fixed tiles
param - phase correlation parameters