trueEbsd2.calcDistortion edit page

fit the distortion separating every consecutive pair of maps

Description

job.T(n) is the unfitted spatialTransform separating map n from map n+1, and stageList expands it into the sequence of stages to fit. For every consecutive pair this divides the images into ROIs, cross correlates them to get a local shift per ROI, and fits the stages to those shifts, each one fitted on what the previous left over. The per stage measurements land in job.shifts{n} as pairShifts, and job.T(n) is replaced by the fitted transform - still of the class it was declared as.

The pairs are not visited in index order. Traversal starts at the first map flagged highContrast, runs forward to the reference, then runs backward from there to map 1, so that one map in every correlated pair has usable edge contrast. Where the other map does not, its partner's intensities are remapped into its frame and that remapped image, not the original, is what the next hop correlates against.

ROI size is optimised by retry: a hop whose residual exceeds 2 pixels is redone with the ROI width doubled, until it converges or the ROI no longer fits the image.

Backends There is one cross correlation, MTEX's xcfShift. 'backend' now chooses only how the resampling is done, and the two ways are interchangeable:

'inverse'   - invert the fitted displacement field and sample on the
              regular grid. About 30× faster at full map size, and the
              default
'scattered' - a forward scatteredInterpolant, what TrueEBSD 2.1.0 ran

They differ on a few hundredths of a percent of pixels, all of them nearest neighbour ties at a cell boundary.

Syntax

job = calcDistortion(job)
job = calcDistortion(job,'fitErr')
job = calcDistortion(job,'fitErr','backend','legacy')   % old resampling

Input

job trueEbsd2, after pixelSizeMatch

Output

job the same trueEbsd2 (a handle), with shifts and job.T fitted and, under 'fitErr', fitError filled in

Options

fitErr measure the residual displacement left after each hop is fitted and print it. This is the number that says whether registration worked, and it is also what the ROI retry below tests against, so without it every hop gets exactly one pass. It costs one extra cross correlation per hop.
silent do not print the progress table
retryMax maximum number of correlation attempts per hop (default 100, in practice unlimited). Each attempt after the first doubles the ROI width. Counts total attempts, not extra ones, so 1 means a single pass; values below 1 are clamped to 1.
backend 'fast' (default) or 'legacy', see below
remapBackend 'inverse' or 'scattered' for the resampling, overriding 'backend'. Picking the halves apart is how you tell which of the two a difference between runs came from.

See also

trueEbsd2.pixelSizeMatch trueEbsd2.undistort spatialTransform xcfShift