private double[,] MockImageEffect(HeightMap h, double brightness) { var result = h.Clone(); h.ForEach((r, c) => { result[r, c] = result[r, c] + brightness; }); return(result.Data); }
// TODO: Test that the mean error of the blur result, // compared to "real" (convolution of gaussian function) // gaussian blur, is within a reasonable threshold. private HeightMap MockImageEffect(HeightMap heightMap, double[,] kernel) { var resultA = new HeightMap(heightMap.Height, heightMap.Width); var resultB = new HeightMap(heightMap.Height, heightMap.Width); int half = 5 / 2; heightMap.ForEach((r, c) => { var sum = 0d; for (var i = 0; i < 5; i++) { var x = MathHelper.Clamp(c + i - half, 0, 4); sum += heightMap[0, x] * kernel[i, 0]; } resultA[r, c] = sum; }); resultA.ForEach((r, c) => { var sum = 0d; for (var i = 0; i < 5; i++) { sum += resultA[0, c] * kernel[i, 0]; } resultB[r, c] = sum; }); return(resultB); }
private double[,] MockImageEffect(HeightMap h) { var result = h.Clone(); h.ForEach((r, c) => { result[r, c] = 1 - result[r, c]; }); return(result.Data); }
private double[,] MockImageEffect(HeightMap h, double intensity) { var result = h.Clone(); h.ForEach((r, c) => { result[r, c] = result[r, c] * intensity; }); return(result.Data); }
private double[,] MockImageEffect(HeightMap h, double gamma) { var result = h.Clone(); double gammaCorrection = 1 / gamma; h.ForEach((r, c) => { result[r, c] = Math.Pow(result[r, c], gammaCorrection); }); return(result.Data); }
private HeightMap CalculateGaussianConvolution(HeightMap source, double[,] kernel, Direction direction) { var result = new HeightMap(source.Height, source.Width); source.ForEach((r, c) => { result[r, c] = CalculatePoint(source, r, c, kernel, direction); }); return(result); }
private HeightMap MockImageEffect(HeightMap h) { var result = h.Clone(); h.ForEach((r, c) => { result[r, c] += 0.1d; }); return(result); }
/// <summary> /// Generate a white noise <see cref="HeightMap"/> /// </summary> public override HeightMap Generate() { var map = new HeightMap(Dimensions); var rand = Seed.HasValue ? new Random(Seed.Value) : new Random(); map.ForEach((r, c) => { map[r, c] = rand.NextDouble(); }); return(map); }
/// <summary> /// Generate a simplex noise <see cref="HeightMap"/> /// </summary> /// <returns></returns> public override HeightMap Generate() { var map = new HeightMap(Dimensions); var noise = new OpenSimplexNoise(Seed ?? DateTime.Now.Ticks); map.ForEach((r, c) => { map[r, c] = (noise.Generate(c * Scale.Width, r * Scale.Height) + 1) / 2; }); return(map); }
public override HeightMap Generate() { var map = new HeightMap(Dimensions); generator = new OpenSimplexNoise(Seed ?? DateTime.Now.Ticks); map.ForEach((r, c) => { map[r, c] = SumOctave(c, r); }); return(map); }
private double[,] MockImageEffect(HeightMap h, double brightness) { const double High = 259d; const double Low = 255d; double F = (High * (brightness + Low)) / (Low * (High - brightness)); var result = h.Clone(); h.ForEach((r, c) => { result[r, c] = F * (result[r, c] - 0.5d) + 0.5d; }); return(result.Data); }