-
Notifications
You must be signed in to change notification settings - Fork 0
/
readreg.m
executable file
·31 lines (26 loc) · 962 Bytes
/
readreg.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
function numreg = readreg()
% readreg reads the registration information contained in the .reg file
% associated with the current image and stores the pixel information in the
% regdata array and the names in the regnames cell array. File name, path
% as well as the arrays are passed through global variables.
% If the file does not exist or can not be read, the function returns -1,
% otherwise returns the number of registration points read
global path file_name regdata regnames
% construct the registration file name
regfilename = [path file_name '.reg'];
% check that the file exists. If not, return -1 and exit
if ~exist(regfilename)
numreg = -1;
return
end
% read the entries into the arrays
try
[xpix, ypix, name] = textread(regfilename,'%f %f %s\n','headerlines',1);
catch
%error reading file
numreg = -1;
return
end
numreg = size(xpix,1);
regdata = [xpix, ypix];
regnames = cellstr(name);