zoukankan      html  css  js  c++  java
  • 极验验证码-判断需要移动的距离

    public static int compare(String file1,String file2,String file3,int threshold){
    int result=0;
    try
    {
    //读取第一张图片
    File fileOne = new File(file1);
    BufferedImage ImageOne = ImageIO.read(fileOne);
    int width = ImageOne.getWidth();//图片宽度
    int height = ImageOne.getHeight();//图片高度
    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);//把图片1数据放入数组
    File fileTwo = new File(file2);
    BufferedImage ImageTwo = ImageIO.read(fileTwo);
    ImageArrayTwo = ImageTwo.getRGB(0,0,width,height,ImageArrayTwo,0,width);//把图片2数据放入数组
    //System.out.println("bgImageRGBData值"+ImageArrayOne[200]+"fullImageRGBData值"+ImageArrayTwo[200]);
    ////图片下半部分
    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("宽度"+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("猜测的轴坐标是"+x);
    result=x;
    //System.out.println("猜测的轴坐标是"+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);//写图片
    return result;
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    return result;
    }

  • 相关阅读:
    Floydtemplate 示例
    dfa hdu 2222 AC自动机示例
    oj 中的 G++ 与 C++ 的区别
    System.Diagnostics.Process.Start(Info)
    自动关闭messagebox
    获取外部程序进程的SQL语句
    php 阿拉伯数字转中文数字 方法
    最新jQuery CHM版中文帮助文档
    parent.myFrame.cols ff 子窗体取得(访问)父窗体中另一子窗体的ID
    Jquery JS 正确的比较两个数字大小的方法
  • 原文地址:https://www.cnblogs.com/tester-huang/p/6386047.html
Copyright © 2011-2022 走看看