how to read images in MATLAB when images are saved in one folder in the form of image(1),i​mage(2)...​.....image​(2000).

10 Ansichten (letzte 30 Tage)
how to read images in MATLAB when images are saved in one folder in the form of image(1),image(2)........image(2000).

Antworten (2)

madhan ravi
madhan ravi am 10 Dez. 2018
string(sprintfc('image(%d).jpg',(1:10)).')
  3 Kommentare
madhan ravi
madhan ravi am 10 Dez. 2018
Thanks for pointing that out then this should do it:
compose("image(%d).jpg", (1:10).')
Stephan
Stephan am 10 Dez. 2018
Note that:
compose("C:\users\projects\images\image(%04d).jpg", (1:10).')
leads to:
Error using compose
Escaped character '\u' is not valid. See 'doc sprintf' for supported special
characters.
In the case of full path names use:
compose("C:\\users\\projects\\images\\image(%04d).jpg", (1:10).')
to avoid this.

Melden Sie sich an, um zu kommentieren.


Stephan
Stephan am 10 Dez. 2018
Bearbeitet: Stephan am 10 Dez. 2018
Hi,
you can use numberedFileNameArray from FEX. Here is an example how to use it:
names = numberedFileNameArray(1,5,'C:\user\projects\image\image(1).jpg','1')'
This results in:
names =
5×1 string array
"C:\user\projects\image\image(1).jpg"
"C:\user\projects\image\image(2).jpg"
"C:\user\projects\image\image(3).jpg"
"C:\user\projects\image\image(4).jpg"
"C:\user\projects\image\image(5).jpg"
You can iterate through this string array and perform your operations on every image for example by a loop or a vectorized operation.
Best regards
Stephan

Community Treasure Hunt

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

Start Hunting!

Translated by