HighMap library (C++)
Loading...
Searching...
No Matches
filters.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
16#pragma once
17
18#include "highmap/array.hpp"
20
21namespace hmap
22{
23
32// clang-format off
33enum neighborhood : int
34{
37 // orthogonal neighbors (N, S, E, W).
38 CROSS
39 // neighbors.
40};
41// clang-format on
42
67Array bulkify(const Array &z,
68 const PrimitiveType &primitive_type,
69 float amp = 1.f,
70 const Array *p_noise_x = nullptr,
71 const Array *p_noise_y = nullptr,
72 glm::vec2 center = {0.5f, 0.5f},
73 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
74
93Array dequantize(const Array &array,
94 std::uint32_t seed,
95 float dither_amplitude = 0.01f,
96 int filtering_iterations = 1);
97
106void equalize(Array &array);
107
121void equalize(Array &array, const Array *p_mask);
122
142void expand(Array &array, int ir, const Array *p_mask, int iterations = 1);
143
156void expand(Array &array, int ir, int iterations = 1);
157
169void expand(Array &array, const Array &kernel, int iterations = 1);
170
185void expand(Array &array,
186 const Array &kernel,
187 const Array *p_mask,
188 int iterations = 1);
189
218void expand_directional(Array &array,
219 int ir,
220 float angle,
221 float aspect_ratio,
222 float anisotropy = 1.f,
223 const Array *p_mask = nullptr);
224
243void expand_talus(Array &z,
244 const Array &mask,
245 float talus,
246 std::uint32_t seed,
247 int ir = 1,
248 float noise_ratio = 0.2f);
283void fill_talus(Array &z,
284 float talus,
285 std::uint32_t seed,
286 int ir = 1,
287 float noise_ratio = 0.2f,
288 const Array *p_seed_mask = nullptr);
289
290void fill_talus(Array &z,
291 const Array &talus,
292 std::uint32_t seed,
293 int ir = 1,
294 float noise_ratio = 0.2f,
295 const Array *p_seed_mask = nullptr);
296
325void fold(Array &array,
326 float vmin,
327 float vmax,
328 int iterations = 3,
329 float k = 0.05f);
330
348void fold(Array &array, int iterations = 3, float k = 0.05f);
349
373void gain(Array &array, float factor, const Array *p_mask);
374
387void gain(Array &array, float factor);
388
415void gamma_correction(Array &array, float gamma, const Array *p_mask);
416
430void gamma_correction(Array &array, float gamma);
431
460void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
461
485void gamma_correction_local(Array &array,
486 float gamma,
487 int ir,
488 const Array *p_mask,
489 float k = 0.1f);
490
512void kuwahara(Array &array, int ir, float mix_ratio = 1.f);
513
542void kuwahara(Array &array, int ir, const Array *p_mask, float mix_ratio = 1.f);
543
573void laplace(Array &array, float sigma = 0.125f, int iterations = 3);
574
596void laplace(Array &array,
597 const Array *p_mask,
598 float sigma = 0.125f,
599 int iterations = 3);
600
615void laplace1d(std::vector<float> &v, float sigma = 0.5f, int iterations = 1);
616
643void laplace_edge_preserving(Array &array,
644 float talus,
645 float sigma = 0.2f,
646 int iterations = 3);
647
673void laplace_edge_preserving(Array &array,
674 float talus,
675 const Array *p_mask,
676 float sigma = 0.2f,
677 int iterations = 3);
678
702void low_pass_high_order(Array &array, int order = 9, float sigma = 1.f);
703
717void make_binary(Array &array, float threshold = 0.f);
718
739void match_histogram(Array &array, const Array &array_reference);
740
769Array mean_shift(const Array &array,
770 int ir,
771 float talus,
772 int iterations = 1,
773 bool talus_weighted = true);
774
775Array mean_shift(const Array &array,
776 int ir,
777 float talus,
778 const Array *p_mask,
779 int iterations = 1,
780 bool talus_weighted = true);
781
801void median_3x3(Array &array, const Array *p_mask);
802
814void median_3x3(Array &array);
815
849Array median_pseudo(const Array &array, int ir);
850
875void normal_displacement(Array &array,
876 float amount = 0.1f,
877 int ir = 0,
878 bool reverse = false);
879
880void normal_displacement(Array &array,
881 const Array *p_mask,
882 float amount = 0.1f,
883 int ir = 0,
884 bool reverse = false);
885
910void plateau(Array &array, const Array *p_mask, int ir, float factor);
911
912void plateau(Array &array, int ir, float factor);
913
932Array quantize(const Array &array, int nlevels, float vmin, float vmax);
933
947Array quantize(const Array &array, int nlevels);
948
971void recast_billow(Array &array, float vref, float k);
972
1000void recast_canyon(Array &array, const Array &vcut, float gamma = 4.f);
1001
1002void recast_canyon(Array &array,
1003 const Array &vcut,
1004 const Array *p_mask,
1005 float gamma = 4.f);
1006
1007void recast_canyon(Array &array,
1008 float vcut,
1009 const Array *p_mask,
1010 float gamma = 4.f,
1011 const Array *p_noise = nullptr);
1012
1013void recast_canyon(Array &array,
1014 float vcut,
1015 float gamma = 4.f,
1016 const Array *p_noise = nullptr);
1017
1047void recast_cliff(Array &array,
1048 float talus,
1049 int ir,
1050 float amplitude,
1051 float gain = 2.f);
1052
1053void recast_cliff(Array &array,
1054 float talus,
1055 int ir,
1056 float amplitude,
1057 const Array *p_mask,
1058 float gain = 2.f);
1059
1092void recast_cliff_directional(Array &array,
1093 float talus,
1094 int ir,
1095 float amplitude,
1096 float angle,
1097 float gain = 2.f);
1098
1099void recast_cliff_directional(Array &array,
1100 float talus,
1101 int ir,
1102 float amplitude,
1103 float angle,
1104 const Array *p_mask,
1105 float gain = 2.f);
1106
1107void recast_cracks(Array &array,
1108 float cut_min = 0.05f,
1109 float cut_max = 0.5f,
1110 float k_smoothing = 0.01f,
1111 float vmin = 0.f,
1112 float vmax = -1.f);
1113
1150void recast_escarpment(Array &array,
1151 int ir = 16,
1152 float ratio = 0.1f,
1153 float scale = 1.f,
1154 bool reverse = false,
1155 bool transpose_effect = false,
1156 float global_scaling = 0.f);
1157
1196void recast_escarpment(Array &array,
1197 const Array *p_mask,
1198 int ir = 16,
1199 float ratio = 0.1f,
1200 float scale = 1.f,
1201 bool reverse = false,
1202 bool transpose_effect = false,
1203 float global_scaling = 0.f);
1204
1236void recast_peak(Array &array, int ir, float gamma = 2.f, float k = 0.1f);
1237
1238void recast_peak(Array &array,
1239 int ir,
1240 const Array *p_mask,
1241 float gamma = 2.f,
1242 float k = 0.1f);
1243
1288void recast_rocky_slopes(Array &array,
1289 float talus,
1290 int ir,
1291 float amplitude,
1292 std::uint32_t seed,
1293 float kw,
1294 float gamma = 0.5f,
1295 const Array *p_noise = nullptr,
1296 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
1297
1298void recast_rocky_slopes(Array &array,
1299 float talus,
1300 int ir,
1301 float amplitude,
1302 std::uint32_t seed,
1303 float kw,
1304 const Array *p_mask,
1305 float gamma = 0.5f,
1306 const Array *p_noise = nullptr,
1307 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
1308
1336void recast_sag(Array &array, float vref, float k);
1337
1338void recast_sag(Array &array,
1339 float vref,
1340 float k,
1341 const Array *p_mask);
1342
1368void recurve(Array &array,
1369 const std::vector<float> &t,
1370 const std::vector<float> &v);
1371
1372void recurve(Array &array,
1373 const std::vector<float> &t,
1374 const std::vector<float> &v,
1375 const Array *p_mask);
1376
1404void recurve_bexp(Array &array, float tau = 0.5f);
1405
1407 const Array *p_mask,
1408 float tau = 0.5f);
1409
1437void recurve_exp(Array &array, float tau = 0.5f);
1438
1439void recurve_exp(Array &array,
1440 const Array *p_mask,
1441 float tau = 0.5f);
1442
1468void recurve_kura(Array &array, float a, float b);
1469
1470void recurve_kura(Array &array,
1471 float a,
1472 float b,
1473 const Array *p_mask);
1474
1496void recurve_s(Array &array);
1497
1498void recurve_s(Array &array, const Array *p_mask);
1499
1524void recurve_smoothstep_rational(Array &array, float n);
1525
1527 float n,
1528 const Array *p_mask);
1529
1558void reverse_above_theshold(Array &array,
1559 const Array &threshold,
1560 float scaling = 1.f,
1561 float transition_extent = 0.f);
1562
1563void reverse_above_theshold(Array &array,
1564 float threshold,
1565 float scaling = 1.f,
1566 float transition_extent = 0.f);
1567
1568void reverse_above_theshold(Array &array,
1569 const Array &threshold,
1570 const Array *p_mask,
1571 float scaling = 1.f,
1572 float transition_extent = 0.f);
1573
1574void reverse_above_theshold(Array &array,
1575 float threshold,
1576 const Array *p_mask,
1577 float scaling = 1.f,
1578 float transition_extent = 0.f);
1579
1602void saturate(Array &array,
1603 float vmin,
1604 float vmax,
1605 float from_min,
1606 float from_max,
1607 float k = 0.f);
1608
1609void saturate(Array &array, float vmin, float vmax, float k = 0.f);
1610// @overload
1611
1630void saturate_percentile(Array &array,
1631 float percentile_low,
1632 float percentile_high,
1633 float k = 0.f);
1634
1659void sharpen(Array &array, float ratio = 1.f);
1660
1661void sharpen(Array &array,
1662 const Array *p_mask,
1663 float ratio = 1.f);
1664
1690void sharpen_cone(Array &array, int ir, float intensity = 0.5f);
1691
1692void sharpen_cone(Array &array,
1693 const Array *p_mask,
1694 int ir,
1695 float scale = 0.5f);
1696
1725void shrink(Array &array, int ir, int iterations = 1);
1726void shrink(Array &array,
1727 int ir,
1728 const Array *p_mask,
1729 int iterations = 1);
1730void shrink(Array &array,
1731 const Array &kernel,
1732 int iterations = 1);
1733void shrink(Array &array,
1734 const Array &kernel,
1735 const Array *p_mask,
1736 int iterations = 1);
1737
1767void shrink_directional(Array &array,
1768 int ir,
1769 float angle,
1770 float aspect_ratio,
1771 float anisotropy = 1.f,
1772 const Array *p_mask = nullptr);
1773
1794void smooth_cone(Array &array, int ir);
1795void smooth_cone(Array &array, int ir, const Array *p_mask);
1796
1822void smooth_cpulse(Array &array, int ir);
1823void smooth_cpulse(Array &array, int ir, const Array *p_mask);
1824
1845 float talus,
1846 float talus_width,
1847 int ir);
1848
1862void smooth_flat(Array &array, int ir);
1863
1886void smooth_gaussian(Array &array, int ir);
1887void smooth_gaussian(Array &array, int ir, const Array *p_mask);
1920void smooth_fill(Array &array,
1921 int ir,
1922 float k = 0.1f,
1923 Array *p_deposition_map = nullptr);
1924
1925void smooth_fill(Array &array,
1926 int ir,
1927 const Array *p_mask,
1928 float k = 0.1f,
1929 Array *p_deposition_map = nullptr);
1930
1954void smooth_fill_holes(Array &array, int ir);
1955void smooth_fill_holes(Array &array,
1956 int ir,
1957 const Array *p_mask);
1958
1982void smooth_fill_smear_peaks(Array &array, int ir);
1983void smooth_fill_smear_peaks(Array &array,
1984 int ir,
1985 const Array *p_mask);
1986
2003void smoothstep_local(Array &array, int ir);
2004
2025void smoothstep_local(Array &array, int ir, const Array *p_mask);
2026
2052void steepen(Array &array, float scale, int ir = 8);
2053void steepen(Array &array,
2054 float scale,
2055 const Array *p_mask,
2056 int ir = 8);
2057
2086void steepen_convective(Array &array,
2087 float angle,
2088 int iterations = 1,
2089 int ir = 0,
2090 float dt = 0.1f);
2091
2092void steepen_convective(Array &array,
2093 float angle,
2094 const Array *p_mask,
2095 int iterations = 1,
2096 int ir = 0,
2097 float dt = 0.1f);
2098
2132void terrace(Array &array,
2133 std::uint32_t seed,
2134 int nlevels,
2135 float gain = 0.9f,
2136 float noise_ratio = 0.f,
2137 const Array *p_noise = nullptr,
2138 float vmin = 0.f,
2139 float vmax = -1.f);
2140
2181void terrace(Array &array,
2182 std::uint32_t seed,
2183 int nlevels,
2184 const Array *p_mask,
2185 float gain = 0.9f,
2186 float noise_ratio = 0.f,
2187 const Array *p_noise = nullptr,
2188 float vmin = 0.f,
2189 float vmax = -1.f);
2190
2191} // namespace hmap
2192
2193namespace hmap::gpu
2194{
2195
2219Array bilateral_filter(const Array &array,
2220 const Array &kernel2d,
2221 const Array &kernel1d,
2222 float kernel1d_value_scaling);
2223
2247Array bilateral_filter(const Array &array,
2248 int ir,
2249 float kernel1d_value_scaling);
2250
2269void directional_blur(Array &array,
2270 float radius,
2271 const Array &angle,
2272 int steps = 32);
2273
2274void directional_blur(Array &array,
2275 float radius,
2276 const Array &angle,
2277 const Array *p_mask,
2278 int steps = 32);
2279
2281void expand(Array &array, int ir, int iterations = 1);
2282void expand(Array &array,
2283 int ir,
2284 const Array *p_mask,
2285 int iterations = 1);
2286void expand(Array &array,
2287 const Array &kernel,
2288 int iterations = 1);
2289void expand(Array &array,
2290 const Array &kernel,
2291 const Array *p_mask,
2292 int iterations = 1);
2293
2295void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
2296void gamma_correction_local(Array &array,
2297 float gamma,
2298 int ir,
2299 const Array *p_mask,
2300 float k = 0.1f);
2301
2303void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
2304void laplace(Array &array,
2305 const Array *p_mask,
2306 float sigma = 0.2f,
2307 int iterations = 3);
2308
2310Array mean_shift(const Array &array,
2311 int ir,
2312 float talus,
2313 int iterations = 1,
2314 bool talus_weighted = true);
2315
2316Array mean_shift(const Array &array,
2317 int ir,
2318 float talus,
2319 const Array *p_mask,
2320 int iterations = 1,
2321 bool talus_weighted = true);
2322
2324void median_3x3(Array &array);
2325void median_3x3(Array &array, const Array *p_mask);
2326
2328Array median_pseudo(const Array &array, int ir);
2329
2331void normal_displacement(Array &array,
2332 float amount = 0.1f,
2333 int ir = 0,
2334 bool reverse = false);
2335void normal_displacement(Array &array,
2336 const Array *p_mask,
2337 float amount = 0.1f,
2338 int ir = 0,
2339 bool reverse = false);
2340
2342void plateau(Array &array, const Array *p_mask, int ir, float factor);
2343void plateau(Array &array, int ir, float factor);
2344
2367Array project_talus_along_direction(const Array &array,
2368 const Array &talus,
2369 int direction = 0,
2370 float vmin = -FLT_MAX);
2371
2372Array project_talus_along_direction(const Array &array,
2373 const Array &talus,
2374 const Array *p_mask,
2375 int direction = 0,
2376 float vmin = -FLT_MAX);
2377
2379void shrink(Array &array, int ir, int iterations = 1);
2380void shrink(Array &array,
2381 int ir,
2382 const Array *p_mask,
2383 int iterations = 1);
2384void shrink(Array &array,
2385 const Array &kernel,
2386 int iterations = 1);
2387void shrink(Array &array,
2388 const Array &kernel,
2389 const Array *p_mask,
2390 int iterations = 1);
2391
2393void smooth_cpulse(Array &array, int ir);
2394
2396void smooth_cpulse(Array &array, int ir, const Array *p_mask);
2397
2399void smooth_cpulse_edge_removing(Array &array,
2400 float talus,
2401 float talus_width,
2402 int ir);
2403
2405void smooth_fill(Array &array,
2406 int ir,
2407 float k = 0.1f,
2408 Array *p_deposition_map = nullptr);
2409void smooth_fill(Array &array,
2410 int ir,
2411 const Array *p_mask,
2412 float k = 0.1f,
2413 Array *p_deposition_map = nullptr);
2414
2416void smooth_fill_holes(Array &array, int ir);
2417void smooth_fill_holes(Array &array,
2418 int ir,
2419 const Array *p_mask);
2420
2422void smooth_fill_smear_peaks(Array &array, int ir);
2423void smooth_fill_smear_peaks(Array &array,
2424 int ir,
2425 const Array *p_mask);
2426
2445Array spectral_equalizer(const Array &array,
2446 const std::vector<float> &weights,
2447 int ir_min,
2448 int ir_max);
2449
2450Array spectral_equalizer(const Array &array,
2451 const std::vector<float> &weights,
2452 int ir_min,
2453 int ir_max,
2454 const Array *p_mask);
2455
2456} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Definition blending.hpp:186
Array project_talus_along_direction(const Array &array, const Array &talus, int direction=0, float vmin=-FLT_MAX)
Projects array values along a given direction using talus attenuation.
Definition filters_gpu.cpp:280
void laplace(Array &array, float sigma=0.2f, int iterations=3)
See hmap::laplace.
Definition filters_gpu.cpp:122
Array median_pseudo(const Array &array, int ir)
See hmap::median_pseudo.
Definition filters_gpu.cpp:209
Array spectral_equalizer(const Array &array, const std::vector< float > &weights, int ir_min, int ir_max)
Spectral equalizer for 2D fields using a multiscale Gaussian pyramid.
Definition spectral_equalizer.cpp:17
void expand(Array &array, int ir, int iterations=1)
See hmap::expand.
Definition filters_gpu.cpp:23
void smooth_fill_smear_peaks(Array &array, int ir)
See hmap::smooth_fill_smear_peaks.
Definition filters_gpu.cpp:512
void smooth_cpulse_edge_removing(Array &array, float talus, float talus_width, int ir)
See hmap::smooth_cpulse_edge_removing.
Definition filters_gpu.cpp:456
void smooth_fill_holes(Array &array, int ir)
See hmap::smooth_fill_holes.
Definition filters_gpu.cpp:489
Array mean_shift(const Array &array, int ir, float talus, int iterations=1, bool talus_weighted=true)
See hmap::mean_shift.
Definition filters_gpu.cpp:144
void shrink(Array &array, int ir, int iterations=1)
See hmap::shrink.
Definition filters_gpu.cpp:341
void directional_blur(Array &array, float radius, const Array &angle, int steps=32)
Applies a directional blur to the input array.
Definition directional_blur.cpp:14
void gamma_correction_local(Array &array, float gamma, int ir, float k=0.1f)
See hmap::gamma_correction_local.
Definition filters_gpu.cpp:77
void smooth_cpulse(Array &array, int ir)
See hmap::smooth_cpulse.
Definition filters_gpu.cpp:403
void normal_displacement(Array &array, float amount=0.1f, int ir=0, bool reverse=false)
See hmap::normal_displacement.
Definition filters_gpu.cpp:216
void smooth_fill(Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
See hmap::smooth_fill.
Definition filters_gpu.cpp:467
Array bilateral_filter(const Array &array, const Array &kernel2d, const Array &kernel1d, float kernel1d_value_scaling)
Apply a bilateral filter to an array.
Definition bilateral_filter.cpp:13
void plateau(Array &array, const Array *p_mask, int ir, float factor)
See hmap::plateau.
Definition filters_gpu.cpp:247
void median_3x3(Array &array)
See hmap::median_3x3.
Definition filters_gpu.cpp:191
Definition algebra.hpp:23
void recast_rocky_slopes(Array &array, float talus, int ir, float amplitude, std::uint32_t seed, float kw, float gamma=0.5f, const Array *p_noise=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Transform heightmap by adding "rock-like" features at higher slopes.
Definition recast.cpp:311
void laplace_edge_preserving(Array &array, float talus, float sigma=0.2f, int iterations=3)
Apply a low-pass anisotropic Laplace filter to the input array.
Definition filters.cpp:333
Array median_pseudo(const Array &array, int ir)
Computes a fast pseudo-median approximation of a local neighborhood in an array.
Definition filters.cpp:551
void equalize(Array &array)
Apply histogram equalization to the array values.
Definition filters.cpp:33
void smooth_fill_holes(Array &array, int ir)
Apply smoothing to fill holes (elliptic concave surfaces).
Definition filters.cpp:913
void terrace(Array &array, std::uint32_t seed, int nlevels, float gain=0.9f, float noise_ratio=0.f, const Array *p_noise=nullptr, float vmin=0.f, float vmax=-1.f)
Applies a terrace effect to the values in an array.
Definition filters.cpp:1040
void fold(Array &array, float vmin, float vmax, int iterations=3, float k=0.05f)
Apply a "folding" filter (successive absolute values) to the array elements.
Definition filters.cpp:143
void saturate(Array &array, float vmin, float vmax, float from_min, float from_max, float k=0.f)
Saturate the array values based on the input interval [vmin, vmax] (the output amplitude is not modif...
Definition recurve.cpp:122
Array threshold(const Array &array, float x0, float x1)
Linear threshold.
Definition math.cpp:400
void steepen(Array &array, float scale, int ir=8)
Steepen (or flatten) the array map.
Definition filters.cpp:978
void make_binary(Array &array, float threshold=0.f)
Convert array values to binary using a threshold.
Definition filters.cpp:406
void smooth_gaussian(Array &array, int ir)
Apply Gaussian filtering to the array.
Definition filters.cpp:849
PrimitiveType
Defines the primitive shape used for synthesis.
Definition functions.hpp:23
void plateau(Array &array, const Array *p_mask, int ir, float factor)
Apply a plateau-shape filter to the input array.
Definition filters.cpp:617
void recast_cliff(Array &array, float talus, int ir, float amplitude, float gain=2.f)
Transform heightmap to add cliffs where gradients are steep enough.
Definition recast.cpp:94
void shrink_directional(Array &array, int ir, float angle, float aspect_ratio, float anisotropy=1.f, const Array *p_mask=nullptr)
Apply directional shrinking, or "deflating", to emphasize the ridges in the terrain.
Definition filters.cpp:749
void sharpen_cone(Array &array, int ir, float intensity=0.5f)
Apply a sharpening filter based on a smooth cone filter.
Definition filters.cpp:706
void laplace(Array &array, float sigma=0.125f, int iterations=3)
Applies an iterative 8-neighbor Laplacian smoothing filter on an array.
Definition filters.cpp:290
void recurve_exp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "sharp exponential-shape" curve.
Definition recurve.cpp:54
Array dequantize(const Array &array, std::uint32_t seed, float dither_amplitude=0.01f, int filtering_iterations=1)
Reduce quantization artifacts using dithering and smoothing.
Definition dequantize.cpp:14
void sharpen(Array &array, float ratio=1.f)
Apply a sharpening filter based on the Laplace operator.
Definition filters.cpp:687
void smooth_flat(Array &array, int ir)
Applies a smoothing average filter to the given 2D array in both dimensions.
Definition filters.cpp:836
void low_pass_high_order(Array &array, int order=9, float sigma=1.f)
Apply a low-pass high-order filter to the input array.
Definition filters.cpp:365
Array quantize(const Array &array, int nlevels, float vmin, float vmax)
Quantize array values into discrete levels.
Definition dequantize.cpp:30
void steepen_convective(Array &array, float angle, int iterations=1, int ir=0, float dt=0.1f)
Steepen array values by applying a nonlinear convection operator in a given direction.
Definition filters.cpp:994
Array mean_shift(const Array &array, int ir, float talus, int iterations=1, bool talus_weighted=true)
Applies the mean shift algorithm to the input array.
Definition filters.cpp:437
void match_histogram(Array &array, const Array &array_reference)
Transform the input array elevation to match the histogram of a reference array.
Definition filters.cpp:416
void expand_talus(Array &z, const Array &mask, float talus, std::uint32_t seed, int ir=1, float noise_ratio=0.2f)
Expand heights outward from a masked region with a talus slope limit.
Definition expand_talus.cpp:18
void median_3x3(Array &array, const Array *p_mask)
Apply a 3x3 median filter to the input array.
Definition filters.cpp:546
void smooth_cpulse(Array &array, int ir)
Apply filtering to the array using convolution with a cubic pulse kernel.
Definition filters.cpp:794
void fill_talus(Array &z, float talus, std::uint32_t seed, int ir=1, float noise_ratio=0.2f, const Array *p_seed_mask=nullptr)
Enforce a talus slope constraint on a height field.
Definition fill_talus.cpp:95
void recurve(Array &array, const std::vector< float > &t, const std::vector< float > &v)
Apply a curve adjustment filter to the array.
Definition recurve.cpp:16
neighborhood
Enum representing different types of neighborhood lattices.
Definition filters.hpp:34
@ VON_NEUMANN
Von Neumann neighborhood: includes only the four.
Definition filters.hpp:36
@ CROSS
Cross-shaped neighborhood: includes only the diagonal.
Definition filters.hpp:38
@ MOORE
Moore neighborhood: includes all eight surrounding cells.
Definition filters.hpp:35
void smoothstep_local(Array &array, int ir)
Applies a localized smoothstep operation to the provided array.
Definition filters.cpp:957
void recurve_s(Array &array)
Apply a curve adjustment filter using a smooth "S-shape" curve.
Definition recurve.cpp:86
void smooth_cpulse_edge_removing(Array &array, float talus, float talus_width, int ir)
Smooths an array while attenuating edges using a gradient-based pulse.
Definition filters.cpp:825
void saturate_percentile(Array &array, float percentile_low, float percentile_high, float k=0.f)
Saturate values based on percentile range.
Definition recurve.cpp:150
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:46
void normal_displacement(Array &array, float amount=0.1f, int ir=0, bool reverse=false)
Apply a displacement to the terrain along the normal direction.
Definition filters.cpp:557
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:173
void reverse_above_theshold(Array &array, const Array &threshold, float scaling=1.f, float transition_extent=0.f)
Applies a smooth reversal of values above a given threshold.
Definition filters.cpp:622
void gamma_correction(Array &array, float gamma, const Array *p_mask)
Apply gamma correction to the input array.
Definition filters.cpp:188
void smooth_cone(Array &array, int ir)
Apply a convolution filter with a cone kernel to smooth the array.
Definition filters.cpp:763
void recast_sag(Array &array, float vref, float k)
Transform heightmap to give a "cliff" like appearance.
Definition recast.cpp:378
void laplace1d(std::vector< float > &v, float sigma=0.5f, int iterations=1)
Apply a low-pass Laplace filter to a vector.
Definition vector.cpp:30
void recast_peak(Array &array, int ir, float gamma=2.f, float k=0.1f)
Transform heightmap to give a "peak" like appearance.
Definition recast.cpp:291
void shrink(Array &array, int ir, int iterations=1)
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
Definition filters.cpp:718
void recast_cliff_directional(Array &array, float talus, int ir, float amplitude, float angle, float gain=2.f)
Transform heightmap to add directional cliffs where gradients are steep enough.
Definition recast.cpp:140
void gamma_correction_local(Array &array, float gamma, int ir, float k=0.1f)
Apply a "local" gamma correction to the input array.
Definition filters.cpp:193
void recast_billow(Array &array, float vref, float k)
Transform heightmap to give a "billow" like appearance.
Definition recast.cpp:25
void kuwahara(Array &array, int ir, float mix_ratio=1.f)
Applies the Kuwahara filter to an array with optional per-pixel masking.
Definition filters.cpp:237
void recast_escarpment(Array &array, int ir=16, float ratio=0.1f, float scale=1.f, bool reverse=false, bool transpose_effect=false, float global_scaling=0.f)
Applies an escarpment effect to the given 2D array, modifying its values based on cumulative displace...
Definition recast.cpp:222
void expand(Array &array, int ir, const Array *p_mask, int iterations=1)
Apply expansion, or "inflation", to emphasize the bulk of the terrain.
Definition filters.cpp:75
Array bulkify(const Array &z, const PrimitiveType &primitive_type, float amp=1.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Applies a primitive-based displacement to an array.
Definition bulkify.cpp:10
void recast_canyon(Array &array, const Array &vcut, float gamma=4.f)
Transform heightmap to give a "canyon" like appearance.
Definition recast.cpp:30
void smooth_fill(Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
Apply cubic pulse smoothing to fill lower flat regions while preserving some sharpness.
Definition filters.cpp:883
void recurve_kura(Array &array, float a, float b)
Apply a curve adjustment filter using Kumaraswamy's cumulative distribution function (CDF).
Definition recurve.cpp:70
void recast_cracks(Array &array, float cut_min=0.05f, float cut_max=0.5f, float k_smoothing=0.01f, float vmin=0.f, float vmax=-1.f)
Definition recast.cpp:198
void recurve_bexp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "bumpy exponential-shape" curve.
Definition recurve.cpp:38
void smooth_fill_smear_peaks(Array &array, int ir)
Apply smoothing to smear peaks (elliptic convex surfaces).
Definition filters.cpp:934
void recurve_smoothstep_rational(Array &array, float n)
Apply a curve adjustment filter using an nth-order smoothstep curve.
Definition recurve.cpp:101
void expand_directional(Array &array, int ir, float angle, float aspect_ratio, float anisotropy=1.f, const Array *p_mask=nullptr)
Apply expansion, or "inflation", to emphasize the bulk of the terrain, using a directional kernel.
Definition filters.cpp:124