O'Reilly logo

Machine Learning for OpenCV by Michael Beyeler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing Principal Component Analysis (PCA) in OpenCV

One of the most common dimensionality reduction techniques is called Principal Component Analysis (PCA).

Similar to the 2D and 3D examples shown earlier, we can think of an image as a point in a high-dimensional space. If we flatten a 2D image of height m and width n by stacking all the columns, we get a (feature) vector of length m n 1. The value of the i-th element in this vector is the grayscale value of the i-th pixel in the image. Now, imagine we would like to represent every possible 2D grayscale image with these exact dimensions. How many images would that give?

Since grayscale pixels usually take values between 0 and 255, there are a total of 256 raised to the power of m n ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required