April 2017
Intermediate to advanced
532 pages
12h 39m
English
The first of these is a function to read an image from a file.
import java.awt.image.BufferedImage def loadImageFromFile(path: String): BufferedImage = { ImageIO.read(new File(path)) }
This preceding code is available in Util.scala.
This returns an instance of a java.awt.image.BufferedImage class, which stores the image data, and provides a number of useful methods. Let's test it out by loading the first image into our Spark shell, as follows:
val aePath = "/PATH/lfw/Aaron_Eckhart/Aaron_Eckhart_0001.jpg" val aeImage = loadImageFromFile(aePath)
You should see the image details displayed in the shell.
aeImage: java.awt.image.BufferedImage = BufferedImage@f41266e: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color ...
Read now
Unlock full access