• 极验验证码-判断需要移动的距离


    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;
    }

  • 相关阅读:
    Random简介
    十道海量数据处理面试题
    Django models 的字段类型
    执行monkey APK 制作
    MTK平台-抓取蓝牙log
    超级硬件代理解决企业Web提速上网问题
    Red Hat Linux 安装 (本地、网络安装)
    由安装两块网卡的linux系统中引起网络不通想到的
    Linux企业应用--RHAS 2.1 下安装中文 Lotus Domino R 6.5 图解
    巧用Linux 架设TFTP Server备份路由器的配置文件
  • 原文地址:https://www.cnblogs.com/tester-huang/p/6386047.html
Copyright © 2020-2023  润新知