I’ve got lots and lots of digital photos. I would like to try and run ImageIdentify on them to see if it can generate useful keywords.
I’m just starting with Mathematica and I don’t see how to write a conventional program of the form
do i = 1 to 3
file_path = directory & filenames[[i]]
ImageIdentify[Import[file_path]]
next
Basically I don’t want to have to force all the parts of the do to be on one line which seems to be the default. To be honest this formatting reminds me of when I had to program in Forth; very painful.
assuming your files are in a folder called “~/Desktop/Images/”. The first line gets all the file names. The second creates and empty list. The Do loop makes a list of images and their identification. The last command plots.
Mathematica is much more elegant than that. You can use functional programming - rather than the procedural style above. The functional version looks like this:
Thanks. The sad reality is that I’ve been programming for 43 years and I’m just more comfortable with standard procedural coding. If I wasn’t doing this for fun I’d knuckle down and learn the new approach but my short term objective is just to be able to code quickly which in my case means using code that is easier for me to read.
The other issue I have is that it’s not obvious to me how to generalize the code you showed for dealing with nested directories.