Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
recherche:methodes:ebsd:ebsd_depth_map [23/10/2020 18:10] – simon.breumier | recherche:methodes:ebsd:ebsd_depth_map [27/10/2020 09:29] (Version actuelle) – simon.breumier | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
=== Compute the depth of each point of a sample relative to its surface whatever its geometry === | === Compute the depth of each point of a sample relative to its surface whatever its geometry === | ||
- | <Code:matlab linenums: | + | The following script computes the ditance field between every point inside a *mask* and a *frontiere curve*: |
- | 1+1 | + | |
+ | < | ||
+ | function [ebsdAct] = add_dep_comp(ebsd, | ||
+ | %Load and adapt | ||
+ | front = imread(front_pic); | ||
+ | masking = imread(mask_pic); | ||
+ | masking = flipdim(masking, | ||
+ | front = flipdim(front, | ||
+ | | ||
+ | I_max = min([size(front, | ||
+ | J_max = min([size(front, | ||
+ | I_min = size(ebsd, | ||
+ | ebsd = ebsd(I_min: | ||
+ | front = front(1: | ||
+ | masking = masking(1: | ||
+ | | ||
+ | % cut frontier | ||
+ | hsvValues = rgb2hsv(front); | ||
+ | hueValue = hsvValues(:,:, | ||
+ | ebsd.prop.hue = hueValue; | ||
+ | |||
+ | ebsdFront = ebsd(ebsd.hue> | ||
+ | |||
+ | % mask | ||
+ | hsvValues2 = rgb2hsv(masking); | ||
+ | hueValue2 = hsvValues2(:,:, | ||
+ | ebsd.prop.mask = hueValue2; | ||
+ | |||
+ | ebsdAct = ebsd(ebsd.mask> | ||
+ | |||
+ | % Get distance with frontiere | ||
+ | distTabAct = 10000*ones(ebsdAct.size); | ||
+ | for i=1: | ||
+ | | ||
+ | | ||
+ | end | ||
+ | | ||
+ | ebsdAct.prop.dep = distTabAct; | ||
+ | end | ||
</ | </ | ||
+ | |||
+ | |||
+ | 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): | ||
+ | |||
+ | {{: | ||
+ | {{: |