Verification code-determine the distance you need to move

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.