Borrar filtros
Borrar filtros

Lanread function in Matlab

2 visualizaciones (últimos 30 días)
Emmanuelle
Emmanuelle el 7 de Feb. de 2013
Respondida: Chetan el 28 de Abr. de 2014
Hello, I have a multispectral image and I've a question. I've found a function code on the internet which allows to read this kind of images. The problem is I received the following error:
??? function [lan_data] = lanread('montana.lan')
|
Error: Function definitions are not
permitted in this context.
Also, when I checked the help of the 'lanread' command I received the following information: ">> help landread landread not found."
Is possible that this command doesn't exist? I haven't found so much information about it.
Thanks in advance,
PD) This is the function code.
function [lan_data] = lanread('montana.lan','C:\formato_lan')
% LANREAD Read Landsat data file type .lan
% Ex: im = lanread('montana.lan')
% size(im) = [m,n,d];
% (From landsatdemo in the image analysis toolbox.)
% $Id: lanread.m 3325 2007-04-06 15:52:34Z finn $
if (nargin<2), thepath = []; end
if isempty(thepath)
[p,n,e]=fileparts(which('fms150path'));
thepath= {fullfile('.',filesep),...
fullfile(p,filesep,'data',filesep),...
fullfile(p,filesep,'data',filesep,'protected',filesep),...
fullfile(p,filesep,'data',filesep,'protected',filesep, ...
'lan',filesep),...
''};
elseif ischar(thepath)
thepath = {thepath};
end
fid = -1;
if (fid<0)
for path_idx=1:length(thepath)
filename = sprintf('%s%s',thepath{path_idx},lan_filename);
fid = fopen(filename,'r');
if (fid>=0), break; end
end
if (fid<0) % If not found anywhere
error(sprintf('Could not open file: %s',filename));
end
end
% find out how big the image is based on file size,
% assuming square image, 7 bands
nbands = 7;
fseek(fid,0,'eof');
file_bytes = ftell(fid);
nlines = floor(sqrt(file_bytes/nbands));
nsamples = nlines;
% skip header
nbytes_header = 128;
fseek(fid,nbytes_header,'bof');
% prepend * to read data into an array that has the same class as the data
A = fread(fid,[nsamples nlines*nbands],'*uint8');
fclose(fid);
% put data into a 3D array
A_3dim = reshape(A,nsamples,nbands,nlines);
lan_data = permute(A_3dim,[3 1 2]);

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Feb. de 2013
You need to save the code in a file named lanread.m and ensure that the file is on your MATLAB path (you might need to use pathtool for that.)
  2 comentarios
Emmanuelle
Emmanuelle el 7 de Feb. de 2013
Hi Walter! Thanks for your quickly reply! ;) I've saved as a lanread.m (I've written in a New file/function). Now the error is: ??? Error: "File: lanread.m Line: 9 Column: 31 Unexpected MATLAB expression.". The problem it's on 'montana.lan'. The error is: "Line 9: Invalid syntax at <STRING<. Posisibly, a ),} or ] is missing", "Line 9: Parse error at ')' usage might be invalid MATLAB syntax.
Emmanuelle
Emmanuelle el 7 de Feb. de 2013
I've just solved. I was confused with that.
function [lan_data] = lanread(lan_filename, thepath)

Iniciar sesión para comentar.

Más respuestas (1)

Chetan
Chetan el 28 de Abr. de 2014
Is this possible to get the video encryption from avi to MPEG2 can be done by this LANREAD function .

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by