How can a particular .tif file be read from a folder which is having 10 files with different suffix like 'file_1', 'file_2'...?I only want to read file_2.tif and file_4.tif.
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Raka Mukherjee
el 2 de En. de 2020
Respondida: Rik
el 2 de En. de 2020
I have used the following code
folder='D\Project';
file2=(dir(fullfile(folder,'*_2.tif)));
This code is returning a structure where the name can be read only. I want the content of the file, as it should have several rows and columns.
How can I use the geotiffread function with it to read the content of the file?
I am stuck in here. I t will be helpful if someone can assist.
0 comentarios
Respuesta aceptada
Rik
el 2 de En. de 2020
You can generate the list of file names with dir:
filelist=dir(fullfile(folder,'*_*.tif'));
Now you can optionally loop through this struct and remove any files that don't match the pattern of files you would like to read. (if you loop backwards, you don't need to worry about skipping any of the elements)
for n=numel(filelist):-1:1
if SomeCondition
filelist(n)=[];
end
end
And now you can use the struct to feed the file names to the geotiffread function, just like the documentation describes:
A=cell(size(filelist));
R=cell(size(filelist));
for n=1:numel(filelist)
fn=fullfile(folder,filelist(n).name);
[A{n},R{n}] = geotiffread(filename);
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!