public static double[][] computeWeightMatrix(int bpp){
  final int dim=bpp * bpp * bpp;
  final double[][] m=new double[dim][dim];
  final double max=3. * (bpp - 1.);
  for (int x=0; x < dim; x++) {
    final int rx=(x / bpp) / bpp;
    final int gx=(x / bpp) % bpp;
    final int bx=x % bpp;
    for (int y=x; y < dim; y++) {
      final int ry=(y / bpp) / bpp;
      final int gy=(y / bpp) % bpp;
      final int by=y % bpp;
      final double dr=Math.abs(rx - ry);
      final double dg=Math.abs(gx - gy);
      final double db=Math.abs(bx - by);
      final double val=1 - (dr + dg + db) / max;
      m[x][y]=m[y][x]=val;
    }
  }
  return m;
}

public static double [ ] [ ] computeWeightMatrix ( int bpp ) { final int dim = bpp * bpp * bpp ; final double [ ] [ ] m = new double [ dim ] [ dim ] ; final double max = 3. * ( bpp - 1. ) ; for ( int x = 0 ; x < dim ; x ++ ) { final int rx = ( x / bpp ) / bpp ; final int gx = ( x / bpp ) % bpp ; final int bx = x % bpp ; for ( int y = x ; y < dim ; y ++ ) { final int ry = ( y / bpp ) / bpp ; final int gy = ( y / bpp ) % bpp ; final int by = y % bpp ; final double dr = Math . abs ( rx - ry ) ; final double dg = Math . abs ( gx - gy ) ; final double db = Math . abs ( bx - by ) ; final double val = 1 - ( dr + dg + db ) / max ; m [ x ] [ y ] = m [ y ] [ x ] = val ; } } return m ; }
compute weight matrix for a rgb color histogram
