Commit 827eef9d0169a8f888a3f2d166bbb00b4271322b
1 parent
fc5776e6
Load .bin files in matlab
Showing
1 changed file
with
25 additions
and
0 deletions
share/openbr/matlab/loadBin.m
0 → 100644
| 1 | +function [x2] = loadBin(filename,reverse) | ||
| 2 | +% [x2] = loadBin(filename,reverse) | ||
| 3 | + | ||
| 4 | + if nargin < 2, | ||
| 5 | + reverse = false; | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + z = fopen(filename,'r'); | ||
| 9 | + if z == -1, | ||
| 10 | + fprintf('Error opening file %s\n',filename); | ||
| 11 | + x2 = 0; | ||
| 12 | + return | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + x = fread(z,1,'int32'); | ||
| 16 | + x1 = fread(z,1,'int32'); | ||
| 17 | + x2 = fread(z,[x1 x],'float32'); | ||
| 18 | + x2 = x2'; | ||
| 19 | + fclose(z); | ||
| 20 | + | ||
| 21 | + if reverse, | ||
| 22 | + sz = size(x2); | ||
| 23 | + x2 = x2'; | ||
| 24 | + x2 = reshape(x2,sz); | ||
| 25 | + end |