refine_hr#
- de_ebsd.index.refine.refine_hr(patterns, master, detector, rotations, pattern_center=None, refine_pattern_center=False, n_tiles=16, samples_per_tile=8, n_steps=15, damping=0.001, keep_best=True, device=None, all_pixels=False, batch_size=None, sample_by='master')[source]#
High-precision joint orientation + pattern-center refinement.
The sub-0.1-degree-capable path. Rather than touching every detector pixel, it importance-samples a few thousand band-edge points spread across a tile grid and runs batched Levenberg-Marquardt on
(R, pattern_center)against the continuous master, over an objective normalized per tile (robust to intensity ramps). The sample budget (n_tiles,samples_per_tile) is the accuracy/speed knob.- Parameters:
- patterns
A detector image
(H, W)or stack(Np, H, W). The raw sampled values are used – the experimental signal is never back-projected or interpolated.- master, detector
The continuous
de_ebsd.sim.MasterPatternand theEBSDDetectorgeometry.- rotations
Seed
orix.quaternion.Rotation, typically a coarse index result.- pattern_center
Noneusesdetector.pattern_center. A(3,)value shares one center across the stack;(Np, 3)gives a per-pattern center. Returned in the same shape.- refine_pattern_center
Refine the pattern center jointly (6 DOF) and return it, or (default) leave it untouched and refine orientation only (3 DOF).
- n_tiles, samples_per_tile
Tiles per detector side and samples kept per tile; the defaults give
256 * 8 = 2048samples. Raising them improves accuracy proportionally.- n_steps
Levenberg-Marquardt steps (default 15); second-order, so a coarse seed sharpens well inside this budget.
- damping
Initial damping, adapted per pattern each step (x0.5 accepted, x3 rejected).
- keep_best
Never return a
(R, pattern_center)scoring below the seed, making refinement monotone.- device
Defaults to
master.data.device; otherwise everything is moved there.- all_pixels
Use every detector pixel instead of the band-edge subsample (slow reference path for validation).
- batch_size
Patterns per mini-batch.
Nonepicks a memory-aware size; the result is identical for any batch size.- sample_by
Which gradient picks the sample pixels.
"master"(default) renders the simulated pattern at the seed and samples its noise-free gradient, so samples land on true band edges."experimental"samples the raw pattern, which on real data is noise-dominated and adds substantial refinement scatter; it is retained for noise-free/synthetic use.
- Returns:
- rotation
orix.quaternion.Rotation The refined orientation(s), in the convention
MasterPattern.projectconsumes.- score
torch.Tensor Mean per-tile NCC per pattern, in
[-1, 1];>=the seed whenkeep_best.- pattern_center
torch.Tensor Only when
refine_pattern_center: the refined pattern center, shaped like the input.
- rotation