I have long code composed of numerous loops. The starting point is an image that is uploaded, and the code analyses the image through multiple steps.
I have 100 images composed of elements, say Ai, Bi and Ci, making titles such as "Ai Bj Ck.tif". I defined i = 1:10, j = 1:10 and k = 1:10, but not all the options exist. For example, image "A5 B2 C9.tif" does not exist.
I want to implement the code into a loop that creates all the possible image titles, then use the if(file.exists(...)){code} to select images that actually exist, then run the entire code on the first image, then the next one, and so on...
To simplify, let the code be simply the image upload and calculation of its dimensions:
Image_name = list()
for(i in 1:10){
for(j in 1:10){
for(k in 1:10)){
Image_name[i, j, k] = paste("A", i, "B", j, "C", k, ".tif", sep= ""))
}}}
if(file.exists(Image_name)){
f = readImage(Image_name)
dim(f)
}
It does not work. It does not create the correct list of images, and does not upload one image at a time to calculate its dimensions. What is wrong? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire