-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrimscan.m
49 lines (44 loc) · 1.7 KB
/
trimscan.m
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [data, dataHeader] = trimscan(data, dataHeader, startPos, endPos)
% TRIMSCAN Trims a B-Scan between two positions.
%
% [data, dataHeader] = TRIMSCAN(data, dataHeader, startPos, endPos) returns
% a matrix (and a header) with the B-Scan between 'startPos' and 'endPos'.
% If the start position is not specified, 'startPos' is set equal to the
% beginning of the scan. Similarly, if the final position is not specified,
% 'endPos' is set equal to the end of the scan.
%
% REQUIRED INPUT:
% data GPR B-Scan data (matrix)
% dataHeader Header info (struct)
%
% OPTIONAL INPUT:
% startPos Starting position (real)
% endPos Ending position (real)
%
% OUTPUT:
% data GPR B-Scan data after trimming (matrix)
% dataHeader Updated header info (struct)
%
% See also: RESIZESCAN.
%
% Developed by quelopelo - IET, FING, UDELAR (2022)
% For more information, visit https://github.com/quelopelo/iet-gpr
% Default value of startPos and endPos
if nargin < 3 || isempty(startPos)
startPos = dataHeader.startPosition;
end
if nargin < 4 || isempty(endPos)
endPos = startPos + dataHeader.numOfColumns / dataHeader.scansPerMeter;
end
% Get the first and last index
xs = (startPos - dataHeader.startPosition) * dataHeader.scansPerMeter;
xe = xs + (endPos - startPos) * dataHeader.scansPerMeter;
is = max(1, floor(xs));
ie = min(dataHeader.numOfColumns, ceil(xe));
% Trim the B-Scam
data = data(:, is:ie);
% Update the header information
dataHeader.startPosition = dataHeader.startPosition + ...
(is - 1) / dataHeader.scansPerMeter;
dataHeader.numOfColumns = size(data, 2);
end