have been, for the past few weeks trying to figure out how I can compare images. From my experience in what I have been working on, I know it is almost impossible to compare two images and get a 100% match but I am not looking for a 100% match either. I have tried to employ different techniques but maybe I havent done them well, or they are just not the right ones. I will outline them below with the problems i ecountered.
PS all the images are in grayscale
Technique 1-
I got a selected number of images, got the pixel values in an array, got the max the maximum and minimum values of these arrays, and tried to compare with the image that is completely different (but with the same background). The problem here is the image seems to lie within the max and the min at times, and works well other times
Technique 2-
I tried to get the average number of pixel by pixel area so that I can use this to compare with my other image, still nothing seems to give me results. with this technique, I would sample say 5 images, get average per pixel area, save to an array. then get another 5 images that Iam comparing with, and do the same but Iam still not getting any results
Technique 3-
I wanted to count the number of white and black pixels but there is something about my array that I dont get, I mean Iam getting results that are of the likes of - -12566464 and not 255 or 0. and when I use getRaster, I end up getting only 0..
below is the code without getRaster()
BufferedImage myImage = null;
int size =imgHeight * imgWidth;
myImage= new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_BYTE_GRAY);
PixelGrabber grabber = new PixelGrabber(myImage, 0, 0, imgWidth , imgHeight , pixels , 0, imgWidth);
try {
grabber.grabPixels();
}
catch (InterruptedException e) {
System.out.println(e);
}
Code with getRaster...I get a value of 0
BufferedImage myImage = null;
int size =imgHeight * imgWidth;
myImage= new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_BYTE_GRAY);
DataBufferByte dbb = (DataBufferByte)myImage.getRaster().getDataBuffer();
byte pixels[] = dbb.getData();
for (byte pix : pixels) {
System.out.println(pix+" ");
}
I would appreciate any help. Thank you