-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistVec.m
More file actions
26 lines (23 loc) · 708 Bytes
/
distVec.m
File metadata and controls
26 lines (23 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function [distVector m middle] = distVec(yPos)
## Calculate distance vector between Y positions of points, mode and interline middle.
uSorted = unique(sort(yPos), "rows");
[rowCount, colCount] = size(uSorted);
minimumSize = 5;
prevDist = 0;
lineCount = 0;
lineSizes = [];
distVector = [];
for rowN = 1:(rowCount - 1)
lineCount++;
distance = abs(uSorted(rowN, 1) - uSorted(rowN + 1, 1));
distVector = [distVector distance];
if (abs(prevDist - distance) > minimumSize)
lineSizes = [lineSizes lineCount];
lineCount = 0;
prevDist = 0;
else
prevDist = distance;
endif
end
m = mode(distVector(find(distVector > minimumSize)));
middle = round(mean(lineSizes) / 2);