diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/io')
28 files changed, 731 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/convert422.m b/SD-VBS/common/toolbox/toolbox_basic/io/convert422.m new file mode 100755 index 0000000..919e82e --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/convert422.m | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | image_current = '/hid/jshi'; | ||
| 2 | |||
| 3 | image_dir = 'vr05_5 '; | ||
| 4 | pg_path = '/hid/jshi/422toppm/422toppm'; | ||
| 5 | |||
| 6 | cm = sprintf('cd %s',image_dir); | ||
| 7 | disp(cm); | ||
| 8 | eval(cm); | ||
| 9 | |||
| 10 | d = dir('seq*'); | ||
| 11 | filename = char(sort({d.name})); | ||
| 12 | |||
| 13 | for j=1:size(filename), | ||
| 14 | cm = sprintf('!%s %s',pg_path,deblank(filename(j,:))); | ||
| 15 | disp(cm); | ||
| 16 | eval(cm); | ||
| 17 | end | ||
| 18 | |||
| 19 | |||
| 20 | %%% change back | ||
| 21 | cm = sprintf('cd %s',image_current); | ||
| 22 | disp(cm);eval(cm); | ||
| 23 | |||
| 24 | |||
| 25 | if 0, | ||
| 26 | deblank(filename(f,:)); | ||
| 27 | end | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/im_vd.m b/SD-VBS/common/toolbox/toolbox_basic/io/im_vd.m new file mode 100755 index 0000000..590cd9b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/im_vd.m | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | function J = im_vd(I); | ||
| 2 | |||
| 3 | J(:,:,1) = I(1:2:end,1:2:end); | ||
| 4 | J(:,:,2) = I(2:2:end,1:2:end); | ||
| 5 | |||
| 6 | montage2(J); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m b/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m new file mode 100755 index 0000000..27a5e4b --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/imread2.m | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | function I = imread2(fname,im_dir); | ||
| 2 | % | ||
| 3 | % I = imread2(fname,im_dir); | ||
| 4 | % | ||
| 5 | |||
| 6 | cur_dir = pwd; | ||
| 7 | |||
| 8 | if nargin>1, | ||
| 9 | cd(im_dir); | ||
| 10 | end | ||
| 11 | |||
| 12 | %%% put on the necessary extension | ||
| 13 | d = dir(fname); | ||
| 14 | |||
| 15 | if isempty(d), | ||
| 16 | d = dir([fname,'*']); | ||
| 17 | end | ||
| 18 | |||
| 19 | if isempty(d), | ||
| 20 | I = []; | ||
| 21 | else | ||
| 22 | |||
| 23 | fname = d.name; | ||
| 24 | |||
| 25 | %%% find extension | ||
| 26 | k = findstr(fname,'.'); | ||
| 27 | ext = fname(k(end)+1:end); | ||
| 28 | |||
| 29 | if (ext == 'bz2'), | ||
| 30 | cm = sprintf('!bzip2 -d %s',fname); | ||
| 31 | disp(cm);eval(cm); | ||
| 32 | I = imread2(fname(1:k(end-1)-1)); | ||
| 33 | cm = sprintf('!bzip2 %s',fname(1:k(end)-1)); | ||
| 34 | disp(cm);eval(cm); | ||
| 35 | elseif (ext == 'ppm'); | ||
| 36 | I = readppm(fname); | ||
| 37 | elseif (ext == 'pgm'); | ||
| 38 | I = readpgm(fname); | ||
| 39 | else | ||
| 40 | I = imread(fname); | ||
| 41 | I = double(I)/255; | ||
| 42 | end | ||
| 43 | end | ||
| 44 | |||
| 45 | cd(cur_dir); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/peek_pgm_size.m b/SD-VBS/common/toolbox/toolbox_basic/io/peek_pgm_size.m new file mode 100755 index 0000000..13e54cd --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/peek_pgm_size.m | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | function [nr,nc] = peek_pgm_size(filename) | ||
| 2 | % function [nr,nc] = peek_pgm_size(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 | |||
| 8 | fid = fopen(filename,'r'); | ||
| 9 | fscanf(fid, 'P5\n'); | ||
| 10 | cmt = '#'; | ||
| 11 | while findstr(cmt, '#'), | ||
| 12 | cmt = fgets(fid); | ||
| 13 | if length(findstr(cmt, '#')) ~= 1, | ||
| 14 | YX = sscanf(cmt, '%d %d'); | ||
| 15 | nc = YX(1); nr = YX(2); | ||
| 16 | end | ||
| 17 | end | ||
| 18 | |||
| 19 | fclose(fid); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m b/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m new file mode 100755 index 0000000..49a35a8 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/pgmread.m | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | function [img,header] = pgmread(filename) | ||
| 2 | % | ||
| 3 | % [img,header] = pgmread(filename) | ||
| 4 | |||
| 5 | [fid, msg] = fopen(filename, 'r'); | ||
| 6 | if fid == -1, | ||
| 7 | error(msg) | ||
| 8 | end | ||
| 9 | |||
| 10 | head = []; | ||
| 11 | good = 0; | ||
| 12 | while (good == 0) , | ||
| 13 | l = fgetl(fid); | ||
| 14 | if (length(l) == 3), | ||
| 15 | if (l == '255'), | ||
| 16 | good = 1; | ||
| 17 | sze = sscanf(header,'%d'); | ||
| 18 | end | ||
| 19 | end | ||
| 20 | header= l; | ||
| 21 | end | ||
| 22 | |||
| 23 | img = fread(fid, sze', 'uchar')'; | ||
| 24 | fclose(fid); | ||
diff --git a/SD-VBS/common/toolbox/toolbox_basic/io/ppmtojpg.m b/SD-VBS/common/toolbox/toolbox_basic/io/ppmtojpg.m new file mode 100755 index 0000000..ce47e45 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/io/ppmtojpg.m | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | function []= ppm2jpg(fname,dlm,ori) | ||
| 2 | % | ||
| 3 | % ppm2jpg(fname,dlm,ori) | ||
| 4 | % | ||
| 5 | % dlm =1, remove the file extension from fname | ||
| 6 | % before convert | ||
| 7 | % ori =1, transpose the image | ||
| 8 | % | ||
| 9 | |||
| 10 | if dlm, | ||
| 11 | dlm = findstr(fname,'.'); | ||
| 12 | fname = fname(1:dlm(end)-1); | ||
| 13 | end | ||
| 14 | |||
| 15 | fname_1 = sprintf('%s.ppm',fname); | ||
| 16 | I = readppm(fname_1); | ||
| 17 | |||
| 18 | if ori == 1, | ||
| 19 | I = permute(I,[2 1 3]); | ||
| 20 | end | ||
| 21 | |||
| 22 | |||
| 23 | fname_2 = sprintf('%s.jpg',fname); | ||
| 24 | |||
