April 2017
Intermediate to advanced
532 pages
12h 39m
English
The final step in the processing pipeline is to extract the actual feature vectors that will be the input to our dimensionality reduction model. As we mentioned earlier, the raw grayscale pixel data will be our features. We will form the vectors by flattening out the two-dimensional pixel matrix. The BufferedImage class provides a utility method to do just this, which we will use in our function as follows:
def getPixelsFromImage(image: BufferedImage): Array[Double] = { val width = image.getWidth val height = image.getHeight val pixels = Array.ofDim[Double](width * height) image.getData.getPixels(0, 0, width, height, pixels) }
We can then combine these three functions into one utility function, which takes ...
Read now
Unlock full access