How to extract the reflectance from a remote sensing image?

4 次查看(过去 30 天)
holle all,
When I use the multibandread function to extract reflectance from a remote sensing image of .dat format, I encountered the following error. Could you please help me identify where the error occurred?
“error using ‘fread’
Invalid precision。
Error multibandread>getPixelInfo (line 455)
tmp = fread(fid, 1, info.precision);
Error multibandread>parseInputs (line 332)
info = getPixelInfo(fid,precision);
Error multibandread (line 111)
info = parseInputs(filename, dims,...
Error test (line 87)
data=multibandread(imgfilename,[lines,samples,9],precision,0,'bsq','ieee-le');”
In this context, 'precision' is as follows: precision=[];
switch datatype
case 1
precision='unit8=>unit8';
case 2
precision='int16=>int16';
case 12
precision='unit16=>unit16';
case 3
precision='int32=>int32';
case 13
precision='unit32=>unit32';
case 4
precision='float32=>float32';
case 5
precision='double=>double';
otherwise
precision='invalid type';
end

回答(1 个)

Aditya Singh
Aditya Singh 2023-7-4
编辑:Aditya Singh 2023-7-4
Hi,
To my understanding you want to know why the error is coming and how to fix,
I have taken the following code sample,
fileID = fopen('doubledata.bin');
precision = ['float32']
A = fread(fileID,[3 3],precision)
I was able to reproduce your issue as this, as with 'float32' it works just fine, but when with any values of "unit" (8,16 or 32), I get an error. Thus, it means that the unit values are not supported by the fread function. The supported type is "uint".
Thus, you should remove the "unit" types from you switch case and the code should work fine.
For more information you can refer to
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by