summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/io/read_scan.m42
1 files changed, 42 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m
new file mode 100755
index 0000000..6ad818a
--- /dev/null
+++ b/SD-VBS/common/toolbox/toolbox_basic/io/read_scan.m
@@ -0,0 +1,42 @@
1function [img,sizeinfo] = pgmread(filename)
2% function img = pgmread(filename)
3% this is my version of pgmread for the pgm file created by XV.
4%
5% this program also corrects for the shifts in the image from pm file.
6
7
8fname_header = sprintf('%s.h01',filename);
9fname_data = sprintf('%s.i01',filename);
10
11fid = fopen(fname_header,'r');
12
13
14done = 0;
15while done~=3,
16 cmt = fgets(fid)
17 if (findstr(cmt,'!matrix size[1]')),
18 nc = sscanf(cmt,'!matrix size[1] :=%d');
19 done = done+1;
20 elseif (findstr(cmt,'!matrix size[2]')),
21 nr = sscanf(cmt,'!matrix size[2] :=%d');
22 done = done+1;
23 elseif (findstr(cmt,'!matrix size[3]')),
24 ns = sscanf(cmt,'!matrix size[3] :=%d');
25 done = done+1;
26 end
27end
28fclose(fid);
29
30fid = fopen(fname_data,'r');
31
32%img = fscanf(fid,'%d',size);
33%img = img';
34
35img = fread(fid,nc*nr*ns,'uint8');
36img = reshape(img,nc,nr,ns);
37
38sizeinfo(1) = nr;
39sizeinfo(2) = nc;
40sizeinfo(3) = ns;
41
42fclose(fid);