How to extract the reflectance from a remote sensing image?

4 visualizaciones (últimos 30 días)
Lou Han
Lou Han el 2 de Jul. de 2023
Editada: Aditya Singh el 4 de Jul. de 2023
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

Respuestas (1)

Aditya Singh
Aditya Singh el 4 de Jul. de 2023
Editada: Aditya Singh el 4 de Jul. de 2023
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!

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by