public static int Compare (String file1,string file2,string file3,int threshold) {
int result=0;
Try
{
Read the first picture
File Fileone = new file (file1);
BufferedImage Imageone = Imageio.read (Fileone);
int width = imageone.getwidth ();//Picture width
int height = imageone.getheight ();//Picture height
Int[]imagearrayone = new Int[width*height];
Int[]imagearraytwo = new Int[width*height];
Int[]imagearraythr = new Int[width*height];
Imagearrayone = Imageone.getrgb (0,0,width,height,imagearrayone,0,width);//Put the picture 1 data into the array
File Filetwo = new file (file2);
BufferedImage imagetwo = Imageio.read (filetwo);
Imagearraytwo = Imagetwo.getrgb (0,0,width,height,imagearraytwo,0,width);//Put the picture 2 data into the array
System.out.println ("Bgimagergbdata value" +imagearrayone[200]+ "Fullimagergbdata value" +imagearraytwo[200]);
Bottom half of the picture
BufferedImage imagenew = new BufferedImage (WIDTH,HEIGHT,BUFFEREDIMAGE.TYPE_INT_RGB);
int count[]=new Int[width];
for (int x = 0; x < width; x = x+1) {
count[x]=0;
}
for (int x = 0; x < width*height; x = x+1) {
if ((Math.Abs (imagearrayone[x]-imagearraytwo[x))) <threshold)
{
imagearraythr[x]=0;
}
else{
count[x%width]++;
System.out.println ("width" +x%width);
IMAGEARRAYTHR[X]=IMAGEARRAYONE[X];
imagearraythr[x]=99999999;
}
}
System.out.println (Arrays.tostring (count));
for (int x = 0; x < width; x = x+1) {
if (count[x]>5)
{
System.out.println ("Guess axis coordinates are" +x);
Result=x;
System.out.println ("Guess axis coordinates are" +count[x]+ "" +count[x+1]);
Break
}
}
Imagenew.setrgb (0,0,width,height,imagearraythr,0,width);
File OutFile = new file (file3);
Imageio.write (imagenew, "JPG", outFile);//write a picture
return result;
}
catch (Exception e)
{
E.printstacktrace ();
}
return result;
}
Verification code-determine the distance you need to move