Introduction
- Generates an openCV mat using Open Simplex noise with multiple octaves
- Uses the excellent implementation of open simplex noise is found here
Code
public static Mat GetFractalOpenSimplexNoise(int width, int height, float initialFrequency, int numOctaves, float Lacunarity, float persistence)
{
Mat mat = GetOpenSimplexNoise(width, height, initialFrequency);
for (int i = 1; i < numOctaves; i++)
{
initialFrequency *= Lacunarity;
Mat temp = GetOpenSimplexNoise(width, height, initialFrequency);
double alpha = 1 / (persistence + 1);
double beta = 1 - alpha;
CvInvoke.AddWeighted(mat, alpha, temp, beta, 0, mat);
persistence *= persistence;
}
return mat;
}
Usage
static void Main(string[] args)
{
Mat mat = GetFractalOpenSimplexNoise(500, 500, 1 / 32f, 3, 2, 0.5f);
CvInvoke.Imshow("test", mat);
CvInvoke.WaitKey(0);
}
Output