public static double distanceBetween(BufferedImage o1, BufferedImage o2){
		double m = 0 ;
		for (int x = 0 ; x < o1.getWidth() ; x++){
			for (int y = 0 ; y < o1.getHeight() ; y ++){
				try {
					int rgb1 = o1.getRGB(x, y); 
					int rgb2 = o2.getRGB(x, y);
					int alpha1 = ((rgb1 >> 24) & 0xff); 
					int alpha2 = ((rgb2 >> 24) & 0xff);
					int r1 = ((rgb1 >> 16) & 0xff);
					int r2 = ((rgb2 >> 16) & 0xff);
					int g1 = ((rgb1 >> 8) & 0xff);
					int g2 = ((rgb2 >> 8)  & 0xff);
					int b1 = (rgb1 & 0xff);
					int b2 = (rgb2 & 0xff);
					assert alpha1 == alpha2 ;
					assert r1 == 0 || r1 == 255 ;
					assert r2 == 0 || r2 == 255 ;
					assert g1 == 0 || g1 == 255 ;
					assert g2 == 0 || g2 == 255 ;
					assert b1 == 0 || b1 == 255 ;
					assert b2 == 0 || b2 == 255 ;
					
					m += (Math.abs(r1 - r2) + Math.abs(g1 - g2) + Math.abs(b1 - b2) + Math.abs(alpha1 - alpha2));
					//m += Math.abs(rgb1 - rgb2);
				}catch (Exception ex){
					throw new RuntimeException("x="+x + "y=" + y + "("+ o1.getWidth() + "," + o2.getWidth() + ")" + "("+ o1.getHeight() + "," + o2.getHeight() + ")",ex);
				}
			}
		}
		return m;
	}