I just started using RStudio, as the available package to analyze my images is in R. I just want to analyze some 50 images which are stored in a folder. How can I read each image (by forming a loop), perform some operation on each image and save the output (my output is a list) as a vector?
UPDATE:
I just wrote a piece of code which is as following:
folder <- "F:/F_diff/1_d/glass/New folder/"      # path to folder that holds multiple .jpg files
file_list <- list.files(path=folder, pattern="*.jpg") # create list of all .jpg files in folder
for (i in 1:length(file_list)){
  assign(file_list[i],   
     #read image
     im2 <- readImage(paste(folder, file_list[i], sep=''))
     #analyze each image
     B <- matrix(im2,nrow=808,ncol=610,byrow=FALSE, dimnames=NULL)
     Haarimtest <- TOS2D(B, smooth = FALSE, nsamples = 100)
     summary(Haarimtest)
 )}
I am getting the following errors:
Error: unexpected symbol in: " #analyze each image B" Haarimtest <- TOS2D(B, smooth = FALSE, nsamples = 100) Error in base::log2(x) : non-numeric argument to mathematical function summary(Haarimtest) Error in summary(Haarimtest) : object 'Haarimtest' not found
)} Error: unexpected ')' in " )"
UPDATE 2
After some tinkering with the code and lot of searching, I was able to run it. The code first imports all 30 .tif images of size 64x64 pixels from a folder and perform some image analysis on each image The updated code is as follows:
> library(tiff) 
  library(LS2W) 
  library(LS2Wstat)
> # path to folder that holds multiple .tif files 
  path <- "C:/Users/Metaheuristics/Documents/MATLAB/diff_64 x64/2D/" 
> # create list of all .tif files in folder 
  files <- list.files(path=path, pattern="*.tif") 
> 
> #import all files  
  for(file in files) {   
  perpos <- which(strsplit(file, "")[[1]]==".")   
  assign(
> gsub(" ","",substr(file, 1, perpos-1)), 
> B<-readTIFF(paste(path,file,sep="")))
> 
  #perform image analysis on individual images   
  Haarimtest <- TOS2D(B, smooth = FALSE, nsamples = 100)            
  summary(Haarimtest)   
  }
Just one problem, I am not being able to save the result.
 
     
    