Compare two hashmaps

1

Hello, I need to buy the values of 2 Hashmaps. I'm doing an Image Matcher using the same amount of colors using this code, but I'm not sure how I can compare them.

public static double DoesMatch2(BufferedImage arg0, BufferedImage arg1){
    HashMap<Color, Integer> pixMap0 = new HashMap<>();
    HashMap<Color, Integer> pixMap1 = new HashMap<>();
    for (int x = arg0.getWidth()-1; x >= 0; x--) {
        for (int y = arg0.getHeight()-1; y >= 0; y--) {
            int clr=  arg0.getRGB(x,y); 
            int  red   = (clr & 0x00ff0000) >> 16;
            int  green = (clr & 0x0000ff00) >> 8;
            int  blue  =  clr & 0x000000ff;
            Color color = new Color(red, green, blue);
            if(pixMap0.containsKey(color)){
                pixMap0.put(color, pixMap0.get(color)+1);
            }else{
                pixMap0.put(color, 1);
            }
        }
    }
    for (int x = arg1.getWidth()-1; x >= 0; x--) {
        for (int y = arg1.getHeight()-1; y >= 0; y--) {
            int clr=  arg1.getRGB(x,y); 
            int  red   = (clr & 0x00ff0000) >> 16;
            int  green = (clr & 0x0000ff00) >> 8;
            int  blue  =  clr & 0x000000ff;
            Color color = new Color(red, green, blue);
            if(pixMap1.containsKey(color)){
                pixMap1.put(color, pixMap0.get(color)+1);
            }else{
                pixMap1.put(color, 1);
            }
        }
    }
    return 0;
}
    
asked by anonymous 25.05.2018 / 21:38

0 answers