How to retrieve image name
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have loaded an image having name '1.bmp' using GUI and stored it in the variable 'im'.Is there a way I can get the filename/image name? I want to do something like this
if ( name(im)='1.bmp')
statement1
elseif (name(im)='2.bmp')
statement2
else
statement 3
And so on? Please help me. I am a beginner. % code end
0 commentaires
Réponses (2)
Image Analyst
le 8 Déc 2017
You need to save the filename string and be able to access it in other functions.
0 commentaires
John D'Errico
le 8 Déc 2017
Having loaded an image into a variable, the original name of the image in the file it was stored in is NOT carried along.
Nothing stops you from retaining that name in a different variable. Or you might even decide to name the image variable in a way that was consistent with the filename, although you cannot name a variable with purely a number. So 1 is not a valid variable name, nor can you start the name of a variable with a number.
3 commentaires
Stephen23
le 8 Déc 2017
Modifié(e) : Stephen23
le 8 Déc 2017
- Do not use path as a variable name, because this is the name of a very important inbuilt function.
- The first output of imgetfile is the full path: split this into the filename and pathname using fileparts.
- compare using strcmpi, not strcmp (unless you are using a case-sensitive OS).
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!