Database Reference
In-Depth Information
val grayImage = processImage(aeImage, 100, 100)
You should see the following output in the console:
grayImage: java.awt.image.BufferedImage =
BufferedImage@21f8ea3b: type = 10 ColorModel: #pixelBits =
8 numComponents = 1 color space =
java.awt.color.ICC_ColorSpace@5cd9d8e9 transparency = 1 has
alpha = false isAlphaPre = false ByteInterleavedRaster:
width = 100 height = 100 #numDataElements 1 dataOff[0] = 0
As you can see from the highlighted output, the image's width and height are indeed 100,
and the number of color components is 1.
Next, we will save the processed image to a temporary location so that we can read it back
and display it in our IPython console:
import javax.imageio.ImageIO
import java.io.File
ImageIO.write(grayImage, "jpg", new File("/tmp/aeGray.jpg"))
You should see a result of true displayed in your console, indicating that we success-
fully saved the image to the aeGray.jpg file in our /tmp directory.
Finally, we will read the image in Python and use matplotlib to display the image. Type
the following code into your IPython Notebook or shell (remember that this should be
open in a new terminal window):
tmpPath = "/tmp/aeGray.jpg"
aeGary = imread(tmpPath)
imshow(aeGary, cmap=plt.cm.gray)
This should display the image (note again, we haven't shown the image here). You should
see that it is grayscale and of slightly worse quality as compared to the original image.
Furthermore, you will notice that the scale of the axes are different, representing the new
100 x 100 dimension instead of the original 250 x 250 size.
Extracting feature vectors
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 gray-
Search WWH ::




Custom Search