diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/io/readpgm_evinfo.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/io/readpgm_evinfo.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/readpgm_evinfo.m b/SD-VBS/common/toolbox/toolbox_basic/io/readpgm_evinfo.m new file mode 100755 index 0000000..69f80ba --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/readpgm_evinfo.m | |||
@@ -0,0 +1,35 @@ | |||
1 | function [img,ev_info] = pgmread_evinfo(filename) | ||
2 | % function img = pgmread(filename) | ||
3 | % this is my version of pgmread for the pgm file created by XV. | ||
4 | % | ||
5 | % return the information in line # | ||
6 | |||
7 | |||
8 | fid = fopen(filename,'r'); | ||
9 | |||
10 | if (fid <0), | ||
11 | error(sprintf('can not find file %s',filename)); | ||
12 | end | ||
13 | |||
14 | fscanf(fid, 'P5\n'); | ||
15 | cmt = '#'; | ||
16 | while findstr(cmt, '#'), | ||
17 | cmt = fgets(fid); | ||
18 | if findstr(cmt,'#'), | ||
19 | ev_info = sscanf(cmt,'# minv: %f, maxv: %f, scale: %f, eigval: %f'); | ||
20 | end | ||
21 | if length(findstr(cmt, '#')) ~= 1, | ||
22 | YX = sscanf(cmt, '%d %d'); | ||
23 | y = YX(1); x = YX(2); | ||
24 | end | ||
25 | end | ||
26 | |||
27 | fgets(fid); | ||
28 | |||
29 | %img = fscanf(fid,'%d',size); | ||
30 | %img = img'; | ||
31 | |||
32 | img = fread(fid,[y,x],'uint8'); | ||
33 | img = img'; | ||
34 | fclose(fid); | ||
35 | |||