how do i sort images into a list in ascening order

8 ビュー (過去 30 日間)
alex
alex 2014 年 2 月 19 日
編集済み: Stephen23 2021 年 4 月 18 日
Hello!
I have these images in the file.
1.bmp , 2.bmp , ..... , 1000.bmp
i use this command: list = dir('*.bmp');
and the results are
list(1)= '1.bmp' , list(2)='10.bmp' , list(3)='11.bmp', list(4)='12.bmp', list(5)='13.bmp',... .....,list(995)='2.bmp',...
What can i do to put them into the list in ascending order??
list(1)='1.bmp' , list(2)='2.bmp' .....
Thank you very much.
  3 件のコメント
Nav Desh
Nav Desh 2017 年 7 月 18 日
gives error:Undefined function or variable 'natsortfiles'. any help?
Stephen23
Stephen23 2017 年 7 月 18 日
編集済み: Stephen23 2021 年 4 月 18 日
@Nav Desh: go to my FEX submission natsortfiles. Click on the big blue button labeled Download (top right-hand corner). Unzip the zip file into your current directory. Enjoy!
>> S = dir('*.txt');
>> S.name
ans =
'1.txt'
ans =
'10.txt'
ans =
'2.txt'
>> S = natsortfiles(S); % alphanumeric sort by filename
>> S.name
ans =
'1.txt'
ans =
'2.txt'
ans =
'10.txt'

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2014 年 2 月 19 日
  3 件のコメント
alex
alex 2014 年 2 月 19 日
編集済み: alex 2014 年 2 月 19 日
C =
1.bmp10.bmp11.bmp12.bmp
>> [S,INDEX] = sort_nat(C)
Cell contents reference from a non-cell array object.
Error in sort_nat (line 62)
num_val(i,z(i,:)) = sscanf(sprintf('%s ',digruns{i}{:}),'%f');
alex
alex 2014 年 2 月 19 日
ok found it
list = dir('*.bmp'); C={list.name} sort_nat(C)
thank you very much!

サインインしてコメントする。

その他の回答 (1 件)

Jorge Lopez
Jorge Lopez 2015 年 12 月 3 日
clear all
clc
Directorio = 'Ruta de guardado de frames';
Frames = dir(fullfile(Directorio, '*.extension'));
Nombres={Frames.name};
[~,name]=sort_nat(Nombres);
%sort_nat es una funcion que se debe descargar y guardar en el mismo directorio donde se ejecuta el programa esta funcion ordena alfanumericamente las palabras incluyendo caracteres especiales.
new_folder=Frames(name);
NumFrames = numel(Frames);
VideoRecuperado = VideoWriter('StegoVideo.mp4','MPEG-4');
VideoRecuperado.FrameRate = FramesRate deseado;
VideoRecuperado.Quality = 80;
open(VideoRecuperado);
for n = 1:NumFrames
full_name= fullfile(Directorio, new_folder(n).name);
I=imread(full_name);
writeVideo(VideoRecuperado, I);
end
close(VideoRecuperado);

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by