@Reference(type=Inproceedings, author={"Turk, M.A.","Pentland, A.P."}, title="Face recognition using eigenfaces", year="1991", booktitle="Computer Vision and Pattern Recognition, 1991. Proceedings CVPR \'91., IEEE Computer Society Conference on", pages={"586 ","591"}, month="jun", number="", volume="", customData={"keywords","eigenfaces;eigenvectors;face images;face recognition system;face space;feature space;human faces;two-dimensional recognition;unsupervised learning;computerised pattern recognition;eigenvalues and eigenfunctions;","doi","10.1109/CVPR.1991.139758"}) public class EigenImages extends Object implements BatchTrainer<FImage>, FeatureExtractor<DoubleFV,FImage>, ReadWriteableBinary
Fundamentally, the EigenImages technique is a way to perform dimensionality
reduction on an image using PCA. This implementation can be trained through
the BatchTrainer
interface (which will internally normalise the data
and perform PCA). Once trained, instances can be used as
FeatureExtractor
s to extract low(er) dimensional features from
images.
Methods are also provided to reconstruct an image from its feature vector
(see and #reconstruct(double[])
, and to
visualise a specific principal component as an image (see
visualisePC(int)
.
Modifier | Constructor and Description |
---|---|
protected |
EigenImages()
For serialisation
|
|
EigenImages(int numComponents)
Construct with the given number of principal components.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
binaryHeader()
Header for binary input.
|
DoubleFV |
extractFeature(FImage img)
Extract features from an object and return them.
|
int |
getNumComponents()
Get the number of PCA components selected by this
EigenImages
object. |
void |
readBinary(DataInput in)
Read internal state from in.
|
FImage |
reconstruct(double[] weights)
Reconstruct an image from a weight vector
|
FImage |
reconstruct(DoubleFV weights)
Reconstruct an image from a weight vector
|
String |
toString() |
void |
train(List<? extends FImage> data)
Train the object with the given data.
|
FImage |
visualisePC(int pc)
Draw a principal component as an image.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
protected EigenImages()
public EigenImages(int numComponents)
numComponents
- the number of PCspublic DoubleFV extractFeature(FImage img)
FeatureExtractor
extractFeature
in interface FeatureExtractor<DoubleFV,FImage>
img
- the object to extract frompublic void train(List<? extends FImage> data)
BatchTrainer
BatchTrainer
s should reset the underlying
model everytime this method is called.train
in interface BatchTrainer<FImage>
data
- the training datapublic FImage reconstruct(DoubleFV weights)
weights
- the weight vectorpublic FImage reconstruct(double[] weights)
weights
- the weight vectorpublic FImage visualisePC(int pc)
pc
- the index of the PC to draw.public void readBinary(DataInput in) throws IOException
ReadableBinary
readBinary
in interface ReadableBinary
in
- source to read from.IOException
- an error reading inputpublic byte[] binaryHeader()
ReadableBinary
binaryHeader
in interface ReadableBinary
binaryHeader
in interface WriteableBinary
public void writeBinary(DataOutput out) throws IOException
WriteableBinary
writeBinary
in interface WriteableBinary
out
- sink to write toIOException
- an error writing to outpublic int getNumComponents()
EigenImages
object.