We read the 20 colored images from the desktop and change them to gray to maintain compatibility with the data and model that we have used so far. Take a look at the following code:
setwd("~/Desktop/image20")temp = list.files(pattern = "*.jpg")mypic <- list()for (i in 1:length(temp)) {mypic[[i]] <- readImage(temp[[i]])}for (i in 1:length(temp)) {mypic[[i]] <- channel(mypic[[i]], "gray")}for (i in 1:length(temp)) {mypic[[i]] <- 1-mypic[[i]]}for (i in 1:length(temp)) {mypic[[i]] <- resize(mypic[[i]], 28, 28)}par(mfrow = c(5,4), mar = rep(0, 4))for (i in 1:length(temp)) plot(mypic[[i]])
As seen previously, we also resize all 20 images to 28 x 28, and the resulting 20 images to be classified are as follows: ...