code: private static Kernel createKernel(float radius, int width, int height)
      {
          final int r = (int) Math.ceil(radius);
          final int rows = r * 2 + 1;
          final float[] matrix = new float[rows];
          final float sigma = radius / 3;
          final float sigma22 = 2 * sigma * sigma;
          final float sigmaPi2 = (float) (2 * Math.PI * sigma);
          final float sqrtSigmaPi2 = (float) Math.sqrt(sigmaPi2);
          final float radius2 = radius * radius;
          float total = 0.0F;
          int index = 0;
  
          for (int row = -r; row <= r; row++)
          {
              final float distance = row * (float) row;
              if (distance > radius2)
              {
                  matrix[index] = 0;
              }
              else
              {
                  matrix[index] = (float) Math.exp(-distance / sigma22) / sqrtSigmaPi2;
              }
              total += matrix[index];
              index++;
          }
          for (int i = 0; i < rows; i++)
          {
              matrix[i] /= total;
          }
  
          final float[] data = new float[width * height];
          System.arraycopy(matrix, 0, data, 0, rows);
  
          return new Kernel(rows, data);
      }
docs: Create a blur kernel.
  
  @param radius The blur radius.
  @param width The image width.
  @param height The image height.
  @return The blur kernel.