public ShapesDataStructure accumulate_n_blur( BigInteger[][] enc_img, int rho_step, double theta_step, BigInteger nsquare, BigInteger enc_0) { BigInteger[][] rho_theta_space = accumulate(enc_img, rho_step, theta_step, nsquare, enc_0); // int w=enc_img.length; // int h=enc_img[0].length; long start_blurring = System.currentTimeMillis(); Blur b = new Blur(); b.setKernel_multiplier(kernel_multiplier); BigInteger blurred[][] = b.filter(rho_theta_space, nsquare, enc_0); long stop_blurring = System.currentTimeMillis(); System.out.println( "HOUGH blurring (with a kernel of radius 2) time(ms): " + (stop_blurring - start_blurring)); // calculate the differences and put them in the data structure // the idea is to use blurring for some points and the original for other points // in such a way to hinder the jig-saw attacks System.out.println( "HOUGH calculating differences radius_rho= " + rho_radius + " ,radius_theta= " + theta_radius); BigInteger minusOne = new BigInteger("-1"); int ws = rho_theta_space.length; int hs = rho_theta_space[0].length; // preparing the data structure for storing the differences long start_preparating_differences = System.currentTimeMillis(); BigInteger[][] points_differences = new BigInteger[ws * hs][((2 * rho_radius + 1) * (2 * theta_radius + 1)) - 1]; Point points[] = new Point[ws * hs]; long stop_preparating_differences = System.currentTimeMillis(); System.out.println( "HOUGH preparating data structure for differences, time(ms): " + (stop_preparating_differences - start_preparating_differences)); // for (int x=0; x<rho_theta_space.length; x++) // for (int y=0; y<rho_theta_space[0].length; y++) // System.out.println(rho_theta_space[x][y]); long start_calculating_differences = System.currentTimeMillis(); int count = 0; for (int i = 0; i < ws; i++) for (int j = 0; j < hs; j++) { Point point = new Point(i, j, rho_theta_space[i][j]); points[count] = point; // size = (2*rho_radius+1)*(2*theta_radius+1)-1); if ((i + j) % 2 == 0) { int counta = 0; for (int i1 = i - rho_radius; i1 < i + rho_radius + 1; i1++) for (int j1 = j - theta_radius; j1 < j + theta_radius + 1; j1++) if (i1 >= 0 && i1 < ws && j1 >= 0 && j1 < hs && !(i1 == i && j1 == j)) { // differences.append( rho_theta_space[i][j]-rho_theta_space[i1][j1]); if (!blurred[i1][j1].equals(blurred[i][j])) { BigInteger c = blurred[i1][j1].modPow(minusOne, nsquare); points_differences[count][counta] = blurred[i][j].multiply(c).mod(nsquare); // System.out.println(points_differences[count][counta]);//==BigInteger.ONE){ } // System.out.println(ws); // System.out.println(hs); // System.out.println(points_differences[count][counta]);//==BigInteger.ONE){ // System.out.println(i+" "+j+" "+rho_theta_space[i][j]); // System.out.println(i1+" "+j1+" "+rho_theta_space[i1][j1]); // System.out.println(); // } counta++; } } else { int counta = 0; for (int i1 = i - rho_radius; i1 < i + rho_radius + 1; i1++) for (int j1 = j - theta_radius; j1 < j + theta_radius + 1; j1++) if (i1 >= 0 && i1 < ws && j1 >= 0 && j1 < hs && !(i1 == i && j1 == j)) { // differences.append( rho_theta_space[i][j]-rho_theta_space[i1][j1]); if (!rho_theta_space[i1][j1].equals(rho_theta_space[i][j])) { BigInteger c = rho_theta_space[i1][j1].modPow(minusOne, nsquare); points_differences[count][counta] = rho_theta_space[i][j].multiply(c).mod(nsquare); // System.out.println(points_differences[count][counta]); } counta++; } } // for (BigInteger g: points_differences[count]) // if (g!=null) // System.out.println(g); count++; // points_differences.put(p, differences); } long stop_calculating_differences = System.currentTimeMillis(); System.out.println( "HOUGH calculating differences done, time(ms): " + (stop_calculating_differences - start_calculating_differences)); return new ShapesDataStructure(points, points_differences); }