In this section, we will read image data into R and explore it further to understand the various characteristics of image data. The code for reading and displaying images is as follows:
# Libraries
library(keras)
library(EBImage)
# Reading and plotting images
setwd("~/Desktop/image18")
temp = list.files(pattern="*.jpg")
mypic <- list()
for (i in 1:length(temp)) {mypic[[i]] <- readImage(temp[i])}
par(mfrow = c(3,6))
for (i in 1:length(temp)) plot(mypic[[i]])
par(mfrow = c(1,1))
As you can see from the preceding code, we will make use of the keras and EBImage libraries. The EBImage library is useful for handling and exploring image data. We will start by reading 18 JPEG image files that are stored in the image18 folder of my computer. These images each contain 6 pictures of bicycles, cars, and airplanes that were downloaded from the internet....