some of my friends have planned to do A F.R. project using a simple algorithm Eigen Faces usnig Principal Component Analysis( by turk and Petland )
I have used the following code to extract pixel values from a Jpeg image , but it gives me negative values wen i print the pixel values!!
I dont know if I can continue with negative values for further computation like finding the co-variance matrix ...eigen vectors etc... ...
If u know anything please reply.....
I have used the following code to extract pixel values from a Jpeg image , but it gives me negative values wen i print the pixel values!!
I dont know if I can continue with negative values for further computation like finding the co-variance matrix ...eigen vectors etc... ...
If u know anything please reply.....
Code:
private byte bytes[]=null;
private double doubles[] = null;
private String filename=null;
private int height = 0;
private int width = 0;
private void readImage() throws FileNotFoundException, IOException {
FileInputStream fIn = new FileInputStream(filename);
JPEGImageDecoder jpeg_decode = JPEGCodec.createJPEGDecoder(fIn);
BufferedImage image = jpeg_decode.decodeAsBufferedImage();
width = image.getWidth();
height = image.getHeight();
int[] rgbdata = new int[width * height];
image.getRGB(0,0,width,height,rgbdata,0,width);
bytes = new byte[rgbdata.length];
doubles = new double[rgbdata.length];
for (int i = 0; i < bytes.length; i++) {
bytes = (byte) (rgbdata & 0xFF);
doubles = (double)(rgbdata);
}
Comment