public static Interval ( this range, int steps ) : double[] | ||
range | this | |
steps | int | |
return | double[] |
public static double[] Interval(this DoubleRange range, int steps)
{
return Interval(range.Min, range.Max, steps);
}
Vector::Interval ( byte a, byte b ) : byte[] | |
Vector::Interval ( byte a, byte b, byte stepSize ) : byte[] | |
Vector::Interval ( byte a, byte b, int steps ) : byte[] | |
Vector::Interval ( this range, byte stepSize ) : byte[] | |
Vector::Interval ( this range, int steps ) : byte[] | |
Vector::Interval ( decimal a, decimal b ) : decimal[] | |
Vector::Interval ( decimal a, decimal b, decimal stepSize ) : decimal[] | |
Vector::Interval ( decimal a, decimal b, int steps ) : decimal[] | |
Vector::Interval ( double a, double b ) : double[] | |
Vector::Interval ( double a, double b, double stepSize ) : double[] | |
Vector::Interval ( double a, double b, int steps ) : double[] | |
Vector::Interval ( this range, double stepSize ) : double[] | |
Vector::Interval ( float a, float b ) : float[] | |
Vector::Interval ( float a, float b, float stepSize ) : float[] | |
Vector::Interval ( float a, float b, int steps ) : float[] | |
Vector::Interval ( this range, float stepSize ) : float[] | |
Vector::Interval ( this range, int steps ) : float[] | |
Vector::Interval ( int a, int b ) : int[] | |
Vector::Interval ( int a, int b, double stepSize ) : int[] | |
Vector::Interval ( int a, int b, int steps ) : int[] | |
Vector::Interval ( this range, double stepSize ) : int[] | |
Vector::Interval ( this range, int steps ) : int[] | |
Vector::Interval ( long a, long b ) : long[] | |
Vector::Interval ( long a, long b, int steps ) : long[] | |
Vector::Interval ( long a, long b, long stepSize ) : long[] | |
Vector::Interval ( sbyte a, sbyte b ) : sbyte[] | |
Vector::Interval ( sbyte a, sbyte b, int steps ) : sbyte[] | |
Vector::Interval ( sbyte a, sbyte b, sbyte stepSize ) : sbyte[] | |
Vector::Interval ( short a, short b ) : short[] | |
Vector::Interval ( short a, short b, int steps ) : short[] | |
Vector::Interval ( short a, short b, short stepSize ) : short[] | |
Vector::Interval ( ulong a, ulong b ) : ulong[] | |
Vector::Interval ( ulong a, ulong b, int steps ) : ulong[] | |
Vector::Interval ( ulong a, ulong b, ulong stepSize ) : ulong[] | |
Vector::Interval ( ushort a, ushort b ) : ushort[] | |
Vector::Interval ( ushort a, ushort b, int steps ) : ushort[] | |
Vector::Interval ( ushort a, ushort b, ushort stepSize ) : ushort[] |
/// <summary> /// Computes the 2-D Gabor kernel. /// </summary> /// public static double[,] Kernel2D(int size, double lambda, double theta, double psi, double sigma, double gamma, bool normalized, GaborKernelKind function) { double sigmaX = sigma; double sigmaY = sigma / gamma; double a = Math.Max( Math.Abs(size * sigmaX * Math.Cos(theta)), Math.Abs(size * sigmaY * Math.Sin(theta))); int xMax = (int)Math.Ceiling(Math.Max(1, a)); double b = Math.Max( Math.Abs(size * sigmaX * Math.Sin(theta)), Math.Abs(size * sigmaY * Math.Cos(theta))); int yMax = (int)Math.Ceiling(Math.Max(1, b)); int[] xValues = Vector.Interval(-xMax, xMax); int[] yValues = Vector.Interval(-yMax, yMax); Accord.Diagnostics.Debug.Assert(xValues.Length == (2 * xMax + 1)); Accord.Diagnostics.Debug.Assert(yValues.Length == (2 * yMax + 1)); double[,] kernel = new double[xValues.Length, yValues.Length]; double sum = 0; switch (function) { case GaborKernelKind.Real: for (int i = 0; i < xValues.Length; i++) { for (int j = 0; j < yValues.Length; j++) { sum += kernel[i, j] = Gabor.RealFunction2D( xValues[i], yValues[j], lambda, theta, psi, sigma, gamma); } } break; case GaborKernelKind.Imaginary: for (int i = 0; i < xValues.Length; i++) { for (int j = 0; j < yValues.Length; j++) { sum += kernel[i, j] = Gabor.ImaginaryFunction2D( xValues[i], yValues[j], lambda, theta, psi, sigma, gamma); } } break; case GaborKernelKind.Magnitude: for (int i = 0; i < xValues.Length; i++) { for (int j = 0; j < yValues.Length; j++) { sum += kernel[i, j] = Gabor.Function2D( xValues[i], yValues[j], lambda, theta, psi, sigma, gamma).Magnitude; } } break; case GaborKernelKind.SquaredMagnitude: for (int i = 0; i < xValues.Length; i++) { for (int j = 0; j < yValues.Length; j++) { double v = Gabor.Function2D( xValues[i], yValues[j], lambda, theta, psi, sigma, gamma).Magnitude; sum += kernel[i, j] = v * v; } } break; } if (normalized) { kernel.Divide(sum, result: kernel); } return(kernel); }