简体   繁体   English

开仓16位右对齐

[英]open bin 16-bit right aligned

I'm trying to open an image file with MATLAB (R2011b). 我正在尝试使用MATLAB(R2011b)打开图像文件。 The program which stored the bin file (Xeneth) says it has the datatype "Images (16-bit right aligned) ( .png; .csv;*.bin)". 存储bin文件(Xeneth)的程序说它的数据类型为“图像(右对齐16位)(. png; .csv; *。bin)”。

In MATLAB, I'm trying to open the file with: 在MATLAB中,我尝试使用以下命令打开文件:

fid=fopen('pathAndFile','r');
A=fread(fid,'inf','uint16');

Unfortunately, it keeps saying "Error using fread Invalid precision." 不幸的是,它一直说“使用fread无效精度时出错”。 An example file can be found here: https://www.dropbox.com/s/d8pj1lrhjsnbmvx/mHSdark_20ms_00014.bin 可以在此处找到示例文件: https : //www.dropbox.com/s/d8pj1lrhjsnbmvx/mHSdark_20ms_00014.bin

Does someone have an idea what could cause the problem? 有人知道什么可能导致问题吗?

I have the same error message in Octave and removing 'inf' solved the problem 我在Octave中有相同的错误消息,删除'inf'解决了问题

close all; clear all;

fid = fopen('mHSdark_20ms_00014.bin');
A = fread(fid, 'uint16');
fclose(fid);

size(A)

Here is an execution result 这是执行结果

octave:5> test
ans =

   20480       1

This is because the optional size argument of fread is a numeric , not a string. 这是因为fread的可选size参数是数字而不是字符串。 That is, instead of 'inf' , the appropriate input is just inf , a number, not a string. 也就是说,代替'inf' ,合适的输入只是inf ,一个数字,而不是字符串。 When you input a string to fread , it thinks you are specifying a precision instead of a size. 输入要fread的字符串时,它认为您是在指定精度而不是大小。

However, the default size is inf , which is why the argument may be omitted. 但是,默认大小为inf ,这就是为什么可以省略该参数的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM