code: public static double RealFunction2D(int x, int y, double wavelength, double orientation, double phaseOffset, double gaussVariance, double aspectRatio) {
  
          double X = x * Math.cos(orientation) + y * Math.sin(orientation);
          double Y = -x * Math.sin(orientation) + y * Math.cos(orientation);
  
          double envelope = Math.exp(-((X * X + aspectRatio * aspectRatio * Y * Y) / (2 * gaussVariance * gaussVariance)));
          double carrier = Math.cos(2 * Math.PI * (X / wavelength) + phaseOffset);
  
          return envelope * carrier;
      }
docs: 2-D Gabor function.
  compute only real part.
  
  @param x             X axis coordinate.
  @param y             Y axis coordinate.
  @param wavelength    Wavelength.
  @param orientation   Orientation.
  @param phaseOffset   Phase offset.
  @param gaussVariance Gaussian variance.
  @param aspectRatio   Aspect ratio.
  @return Gabor response.