How does the following code works?
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
r_idx = random('unid', size(listing, 1));
im_input = imread(strcat('D:\project\CVPR17_training_code\data_generation\image\input\', listing(r_idx).name));
I found this code .But ,I couldn't understand how the random() and size() function works.Please explain this...
3 Kommentare
Walter Roberson
am 19 Feb. 2018
You can also use
r_idx = randi(length (listing)) ;
The idea is to choose a random positive integer from 1 to the number of files available, and then use that random integer to select the corresponding file name.
Dhanubala A
am 19 Feb. 2018
Walter Roberson
am 19 Feb. 2018
As an outside person, I have no reason to expect that you have given the correct path to the files.
You should learn how to use fullfile()
projectdir = 'D:\etc'
listing = dir( fullfile(projectdir, '*.jpg'));
ridx = randi(length (listing))
thisfile = fullfile (projectdir, listing(ridx).name));
imread(thisfile)
Antworten (0)
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!