How to compare images for similarity using java

后端 未结 3 1761
梦谈多话
梦谈多话 2020-12-01 14:19

Recently I got an opportunity to work with Image Processing Technologies as a part of one of my projects and my task was to find matching images from an image store when a n

3条回答
  •  抹茶落季
    2020-12-01 14:54

        **// This API will compare two image file //
    // return true if both image files are equal else return false//**
    public static boolean compareImage(File fileA, File fileB) {        
        try {
            // take buffer data from botm image files //
            BufferedImage biA = ImageIO.read(fileA);
            DataBuffer dbA = biA.getData().getDataBuffer();
            int sizeA = dbA.getSize();                      
            BufferedImage biB = ImageIO.read(fileB);
            DataBuffer dbB = biB.getData().getDataBuffer();
            int sizeB = dbB.getSize();
            // compare data-buffer objects //
            if(sizeA == sizeB) {
                for(int i=0; i

提交回复
热议问题