Closed latmarat closed 8 years ago
Hi,
thank you for reporting this issue. However, I do not think I can fix this within the function as intersect
takes as input only boundary segments and does not know about grains. Maybe you can check afterwards, whether a segment is within a grain or not. E.g. by
% restrict to the intersection points
xi = xi(~isnan(xi));
yi = yi(~isnan(yi));
% compute the midpoints - this requires that the points are ordered - which is here the case but in general might not
mpx = 0.5*(xi(1:end-1)+xi(2:end));
mpy = 0.5*(yi(1:end-1)+yi(2:end));
% the checks whether the midpoints are inside the given grains
any(grains.checkInside([mpx(:),mpy(:)]),2)
I hope this helps,
Ralf.
Hello:
intersect
is a really nice function but there is a small bug that may not always show up.If I remove boundary grains or have a hole between "good" grains for whatever reason,
intersect
counts segments outside good grains and adds them to the output array segLength, while it shouldn't. See figure below.We can see that here the right number of segments is 3 but
intersect
will give 4 segments (see code below)Perhaps, there should be additional
inside
condition for the adjacency matrix with good grains as input but so far I couldn't figure out a fast way to do that. Could you please fix this or suggest a temporary work-around?Thanks, Marat
Code