+ * One significant difficulty is that stage coordinates are expressed in an + * arbitrary stage unit, rather than anything convertible such as pixels or + * microns. Hence, we must use some kind of heuristic to convert from stage + * units to pixels, which is what the Fiji stitching plugin requires as input. + *

+ *

+ * The current approach requires the user to provide a rough approximation of + * tile overlap as a percentage, with a default of 20% overlap. We assume image + * tiles were collected in a roughly rectangular grid; the heuristic will + * probably fail with most other tile configurations. + *

+ *

+ * The stage unit scaling algorithm (implemented in the {@link #computeScale} + * method below) is as follows: + *

+ *
1. Get the list of X stage coordinates for all tiles, and sort it in + * ascending order.
2. + *
3. Compute the smallest difference between adjacent X coordinates, above a + * certain minimum threshold (default 20.0). This accounts for duplicate + * coordinates, as well as minor jitter or drift between tiles. This smallest + * difference value represents the X spacing between adjacent tiles in the grid. + *
4. + *
5. Compute this same distance in pixels, which is equal to the tile width + * times the non-overlapping tile fraction; e.g., if the overlap is set to 10%, + * then the pixel width between adjacent tiles is 90% of tile width.
6. + *
7. The scale factor to convert from stage units to pixels is then the ratio + * of these two values: pixelDistance / stageUnitDistance
8. + *
9. This computation is repeated for the Y and Z dimensions as well.
10. + *
+ *

+ *

+ * Once we have the stage unit scale factors, we can write out the stage + * positions to the tile configuration file in pixels, for use by the Fiji + * stitching plugin. There is one other minor detail, however: the stage + * positions may be in a reverse coordinate system from the pixels. Hence, we + * provide an "Invert stage coordinates" checkbox to indicate this. With this + * option enabled, the stage unit scale factors will be negative, which will + * result in the conversion to pixels in the proper direction. + *

+ * + *
Source code:
+ *
Trac, + * SVN