private Complex[] ft(byte[] img, int width, int height, boolean withoutCentering) {
   Complex[] F = new Complex[width * height];
   for (int u = 0; u < height; u++) {
     for (int v = 0; v < width; v++) {
       F[u * width + v] = new Complex();
       for (int x = 0; x < height; x++) {
         for (int y = 0; y < width; y++) {
           double a =
               (double) (img[x * width + y] & 0xFF) * (withoutCentering ? 1 : Math.pow(-1, x + y));
           double b = -2.0 * Math.PI * (u * x / (double) height + v * y / (double) width);
           Complex c = Complex.fromPolar(1, b).mul(a);
           F[u * width + v] = F[u * width + v].plus(c);
         }
       }
     }
   }
   return F;
 }
 private void ift(Complex[] F, byte[] img, int width, int height) {
   for (int x = 0; x < height; x++) {
     for (int y = 0; y < width; y++) {
       Complex c = new Complex();
       for (int u = 0; u < height; u++) {
         for (int v = 0; v < width; v++) {
           Complex tmp =
               Complex.fromPolar(
                   1, 2.0 * Math.PI * (u * x / (double) height + v * y / (double) width));
           c = c.plus(tmp.mul(F[u * width + v]));
         }
       }
       c = c.div(height * width);
       c = c.mul(Math.pow(-1, (x + y)));
       if (c.getReal() < 0) c.setReal(0.0);
       System.out.println(c.getReal());
       img[x * width + y] = (byte) (c.getReal());
     }
   }
 }