Compute the depth of each point of a sample relative to its surface whatever its geometry

The following script computes the ditance field between every point inside a *mask* and a *frontiere curve*:

The script takes three arguments:

ebsd: the MTEX ebsd map object to put the distance field in. Note that the field dimensions should be the same than the picture resolution.

front_pic: A picture where everything is black and white except the frontiere line.

mask_pic: A picture where everything is black and white except the sample points used to compute the distance.

Here are two examples of picture that worked for me (left: frontiere, right: mask):