resample each chain at a constant spacing along its length
Description
Places new vertices at equal arc length along each chain, between the vertices that have to survive, which stay exactly where they are. The new vertices lie on the old boundary, so this changes nothing about its shape - it only changes how it is sampled.
A chain is cut into pieces that are resampled independently at every vertex that may not move: its two junctions, a vertex where the neighbouring grains change, and anything passed in as 'protect'. A chain resampled in one piece visits none of the ones in between, which leaves the inner boundary hanging off a vertex the outer walk no longer reaches, and lets a segment carry the grainId pair of its neighbour.
This is what makes a subsequent grain2d/smoothBoundary work properly. Subdividing each segment, as grain2d/refineBoundary used to do on its own, preserves the staircase of the pixel grid and only makes it finer. Resampling at equal arc length instead gives the smoothing evenly spaced degrees of freedom that are not tied to the grid.
grainId and phaseId are constant along a chain and carry over exactly. ebsdId and misrotation belong to a specific pair of pixels, which a resampled segment no longer corresponds to - those are inherited from whichever original segment covers the new segment's midpoint. A midpoint landing on the seam between two of them is covered by both, and which one it takes is then decided by the last bits of the arc length.
Syntax
gB_r = refine(gB)
gB_r = refine(gB,delta)
gB_r = refine(gB,delta,'protect',vertexIds)Input
| gB | grainBoundary |
| delta | target segment length (default: half the median segment length - a sample every median length may cut a corner per sample where the segments are not all of the same length, half of it follows the original polyline closely) |
Output
| gB_r | grainBoundary |
Options
| protect | ids of vertices that must survive, on top of the junctions |
See also
grainBoundary.simplify grainBoundary.reduce grain2d.refineBoundary grain2d.smoothBoundary