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"
19#include "highmap/kernels.hpp"
23
24namespace hmap
25{
26
27class Cloud;
28class Point;
29class ICommunicator;
30struct ComputeMode;
31struct VirtualArray;
32
36enum class DistanceMode : int
37{
40};
41
45enum class DistanceMethod : int
46{
47 RT = 0,
49};
50
75Array bulkify(const Array &z,
76 const PrimitiveType &primitive_type,
77 float amp = 1.f,
78 const Array *p_noise_x = nullptr,
79 const Array *p_noise_y = nullptr,
80 glm::vec2 center = {0.5f, 0.5f},
81 const UvRect &uv_rect = UvRect::unit());
82
111void canyonize(Array &array,
112 std::uint32_t seed = 0,
113 int nlevels = 6,
114 float convex_ratio = 3.0f,
115 float gamma_convex = 3.0f,
116 float gamma_concave = 0.3f,
117 float clamp_min_val = -std::numeric_limits<float>::infinity(),
118 float k_smooth = 0.1f,
119 float noise_ratio = 0.2f,
120 const Array *p_noise = nullptr,
121 float vmin = 1.f,
122 float vmax = 0.f);
123
145void canyonize(Array &array,
146 std::uint32_t seed,
147 int nlevels,
148 const Array *p_mask,
149 float convex_ratio = 3.0f,
150 float gamma_convex = 3.0f,
151 float gamma_concave = 0.3f,
152 float clamp_min_val = -std::numeric_limits<float>::infinity(),
153 float k_smooth = 0.1f,
154 float noise_ratio = 0.2f,
155 const Array *p_noise = nullptr,
156 float vmin = 1.f,
157 float vmax = 0.f);
158
177Array dequantize(const Array &array,
178 std::uint32_t seed,
179 float dither_amplitude = 0.01f,
180 int filtering_iterations = 1);
181
218Array distance_shaper(const Array &array,
219 float falloff = 0.05f,
220 int directions = 8,
221 float skew = 0.f,
222 float angle = 0.f,
225 float angular_jitter = 0.f,
226 float falloff_jitter = 0.f,
227 float threshold = 0.f,
228 bool invert_input = false,
229 bool invert_output = false,
230 float mix_ratio = 1.f,
231 std::uint32_t seed = 0,
232 const Array *p_mask = nullptr,
233 const Array *p_dx = nullptr,
234 const Array *p_dy = nullptr);
235
244void equalize(Array &array);
245
259void equalize(Array &array, const Array *p_mask);
260
280void expand(Array &array, int ir, const Array *p_mask, int iterations = 1);
281
294void expand(Array &array, int ir, int iterations = 1);
295
307void expand(Array &array, const Array &kernel, int iterations = 1);
308
323void expand(Array &array,
324 const Array &kernel,
325 const Array *p_mask,
326 int iterations = 1);
327
356void expand_directional(Array &array,
357 int ir,
358 float angle,
359 float aspect_ratio,
360 float anisotropy = 1.f,
361 const Array *p_mask = nullptr);
362
381void expand_talus(Array &z,
382 const Array &mask,
383 float talus,
384 std::uint32_t seed,
385 int ir = 1,
386 float noise_ratio = 0.2f);
387
422void fill_talus(Array &z,
423 float talus,
424 std::uint32_t seed,
425 int ir = 1,
426 float noise_ratio = 0.2f,
427 const Array *p_seed_mask = nullptr);
428
429void fill_talus(Array &z,
430 const Array &talus,
431 std::uint32_t seed,
432 int ir = 1,
433 float noise_ratio = 0.2f,
434 const Array *p_seed_mask = nullptr);
435
464void fold(Array &array,
465 float vmin,
466 float vmax,
467 int iterations = 3,
468 float k = 0.05f);
469
487void fold(Array &array, int iterations = 3, float k = 0.05f);
488
509void fold_periodic(Array &array,
510 PhasorProfile phasor_profile,
511 float vmin,
512 float vmax,
513 int iterations = 3,
514 float delta = 0.f);
515
531void fold_periodic(Array &array,
533 int iterations = 3,
534 float delta = 0.f);
535
559void gain(Array &array, float factor, const Array *p_mask);
560
573void gain(Array &array, float factor);
574
601void gamma_correction(Array &array, float gamma, const Array *p_mask);
602
616void gamma_correction(Array &array, float gamma);
617
646void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
647
671void gamma_correction_local(Array &array,
672 float gamma,
673 int ir,
674 const Array *p_mask,
675 float k = 0.1f);
676
698void kuwahara(Array &array, int ir, float mix_ratio = 1.f);
699
728void kuwahara(Array &array, int ir, const Array *p_mask, float mix_ratio = 1.f);
729
759void laplace(Array &array, float sigma = 0.125f, int iterations = 3);
760
782void laplace(Array &array,
783 const Array *p_mask,
784 float sigma = 0.125f,
785 int iterations = 3);
786
801void laplace1d(std::vector<float> &v, float sigma = 0.5f, int iterations = 1);
802
830 float talus,
831 float sigma = 0.2f,
832 int iterations = 3);
833
860 float talus,
861 const Array *p_mask,
862 float sigma = 0.2f,
863 int iterations = 3);
864
888void low_pass_high_order(Array &array, int order = 9, float sigma = 1.f);
889
903void make_binary(Array &array, float threshold = 0.f);
904
928void match_histogram(Array &array, const Array &array_reference);
929
958Array mean_shift(const Array &array,
959 int ir,
960 float talus,
961 int iterations = 1,
962 bool talus_weighted = true);
963
964Array mean_shift(const Array &array,
965 int ir,
966 float talus,
967 const Array *p_mask,
968 int iterations = 1,
969 bool talus_weighted = true);
970
990void median_3x3(Array &array, const Array *p_mask);
991
1003void median_3x3(Array &array);
1004
1038Array median_pseudo(const Array &array, int ir);
1039
1064void normal_displacement(Array &array,
1065 float amount = 0.1f,
1066 int ir = 0,
1067 bool reverse = false);
1068
1070void normal_displacement(Array &array,
1071 const Array *p_mask,
1072 float amount = 0.1f,
1073 int ir = 0,
1074 bool reverse = false);
1075
1100void plateau(Array &array, const Array *p_mask, int ir, float factor);
1101
1103void plateau(Array &array, int ir, float factor);
1104
1123Array quantize(const Array &array, int nlevels, float vmin, float vmax);
1124
1138Array quantize(const Array &array, int nlevels);
1139
1162void recast_billow(Array &array, float vref, float k);
1163
1191void recast_canyon(Array &array, const Array &vcut, float gamma = 4.f);
1192
1194void recast_canyon(Array &array,
1195 const Array &vcut,
1196 const Array *p_mask,
1197 float gamma = 4.f);
1198
1200void recast_canyon(Array &array,
1201 float vcut,
1202 const Array *p_mask,
1203 float gamma = 4.f,
1204 const Array *p_noise = nullptr);
1205
1207void recast_canyon(Array &array,
1208 float vcut,
1209 float gamma = 4.f,
1210 const Array *p_noise = nullptr);
1211void recast_cracks(Array &array,
1212 float cut_min = 0.05f,
1213 float cut_max = 0.5f,
1214 float k_smoothing = 0.01f,
1215 float vmin = 0.f,
1216 float vmax = -1.f);
1217
1254void recast_escarpment(Array &array,
1255 int ir = 16,
1256 float ratio = 0.1f,
1257 float scale = 1.f,
1258 bool reverse = false,
1259 bool transpose_effect = false,
1260 float global_scaling = 0.f);
1261
1300void recast_escarpment(Array &array,
1301 const Array *p_mask,
1302 int ir = 16,
1303 float ratio = 0.1f,
1304 float scale = 1.f,
1305 bool reverse = false,
1306 bool transpose_effect = false,
1307 float global_scaling = 0.f);
1308
1340void recast_peak(Array &array, int ir, float gamma = 2.f, float k = 0.1f);
1341
1343void recast_peak(Array &array,
1344 int ir,
1345 const Array *p_mask,
1346 float gamma = 2.f,
1347 float k = 0.1f);
1348
1393void recast_rocky_slopes(Array &array,
1394 float talus,
1395 int ir,
1396 float amplitude,
1397 std::uint32_t seed,
1398 float kw,
1399 float gamma = 0.5f,
1400 const Array *p_noise = nullptr,
1401 const UvRect &uv_rect = UvRect::unit());
1402
1404void recast_rocky_slopes(Array &array,
1405 float talus,
1406 int ir,
1407 float amplitude,
1408 std::uint32_t seed,
1409 float kw,
1410 const Array *p_mask,
1411 float gamma = 0.5f,
1412 const Array *p_noise = nullptr,
1413 const UvRect &uv_rect = UvRect::unit());
1414
1442void recast_sag(Array &array, float vref, float k);
1443
1445void recast_sag(Array &array, float vref, float k, const Array *p_mask);
1446
1472void recurve(Array &array,
1473 const std::vector<float> &t,
1474 const std::vector<float> &v);
1475
1477void recurve(Array &array,
1478 const std::vector<float> &t,
1479 const std::vector<float> &v,
1480 const Array *p_mask);
1481
1509void recurve_bexp(Array &array, float tau = 0.5f);
1510
1512void recurve_bexp(Array &array, const Array *p_mask, float tau = 0.5f);
1513
1541void recurve_exp(Array &array, float tau = 0.5f);
1542
1544void recurve_exp(Array &array, const Array *p_mask, float tau = 0.5f);
1545
1571void recurve_kura(Array &array, float a, float b);
1572
1574void recurve_kura(Array &array, float a, float b, const Array *p_mask);
1575
1597void recurve_s(Array &array);
1598
1600void recurve_s(Array &array, const Array *p_mask);
1601
1626void recurve_smoothstep_rational(Array &array, float n);
1627
1629void recurve_smoothstep_rational(Array &array, float n, const Array *p_mask);
1630
1659void reverse_above_theshold(Array &array,
1660 const Array &threshold,
1661 float scaling = 1.f,
1662 float transition_extent = 0.f);
1663
1665void reverse_above_theshold(Array &array,
1666 float threshold,
1667 float scaling = 1.f,
1668 float transition_extent = 0.f);
1669
1671void reverse_above_theshold(Array &array,
1672 const Array &threshold,
1673 const Array *p_mask,
1674 float scaling = 1.f,
1675 float transition_extent = 0.f);
1676
1678void reverse_above_theshold(Array &array,
1679 float threshold,
1680 const Array *p_mask,
1681 float scaling = 1.f,
1682 float transition_extent = 0.f);
1683
1707void ridge_accentuate(Array &array,
1708 float strength = 0.1f,
1709 int ir = 0,
1710 bool reverse = false);
1711
1713void ridge_accentuate(Array &array,
1714 const Array *p_mask,
1715 float strength = 0.1f,
1716 int ir = 0,
1717 bool reverse = false);
1718
1741void saturate(Array &array,
1742 float vmin,
1743 float vmax,
1744 float from_min,
1745 float from_max,
1746 float k = 0.f);
1747
1748void saturate(Array &array, float vmin, float vmax, float k = 0.f);
1749// @overload
1750
1769void saturate_percentile(Array &array,
1770 float percentile_low,
1771 float percentile_high,
1772 float k = 0.f);
1773
1798void sharpen(Array &array, float ratio = 1.f);
1799
1801void sharpen(Array &array, const Array *p_mask, float ratio = 1.f);
1802
1828void sharpen_cone(Array &array, int ir, float intensity = 0.5f);
1829
1831void sharpen_cone(Array &array,
1832 const Array *p_mask,
1833 int ir,
1834 float scale = 0.5f);
1835
1864void shrink(Array &array, int ir, int iterations = 1);
1865
1867void shrink(Array &array, int ir, const Array *p_mask, int iterations = 1);
1868
1870void shrink(Array &array, const Array &kernel, int iterations = 1);
1871
1873void shrink(Array &array,
1874 const Array &kernel,
1875 const Array *p_mask,
1876 int iterations = 1);
1877
1907void shrink_directional(Array &array,
1908 int ir,
1909 float angle,
1910 float aspect_ratio,
1911 float anisotropy = 1.f,
1912 const Array *p_mask = nullptr);
1913
1934void smooth_cone(Array &array, int ir);
1935
1937void smooth_cone(Array &array, int ir, const Array *p_mask);
1938
1964void smooth_cpulse(Array &array,
1965 int ir,
1966 const Array *p_mask = nullptr,
1967 const UvTile &region = UvTile::dummy(),
1969
1990 float talus,
1991 float talus_width,
1992 int ir);
1993
2007void smooth_flat(Array &array, int ir);
2008
2031void smooth_gaussian(Array &array, int ir);
2032
2034void smooth_gaussian(Array &array, int ir, const Array *p_mask);
2035
2068void smooth_fill(Array &array,
2069 int ir,
2070 float k = 0.1f,
2071 Array *p_deposition_map = nullptr);
2072
2074void smooth_fill(Array &array,
2075 int ir,
2076 const Array *p_mask,
2077 float k = 0.1f,
2078 Array *p_deposition_map = nullptr);
2079
2103void smooth_fill_holes(Array &array, int ir);
2104
2106void smooth_fill_holes(Array &array, int ir, const Array *p_mask);
2107
2131void smooth_fill_smear_peaks(Array &array, int ir);
2132
2134void smooth_fill_smear_peaks(Array &array, int ir, const Array *p_mask);
2135
2152void smoothstep_local(Array &array, int ir);
2153
2174void smoothstep_local(Array &array, int ir, const Array *p_mask);
2175
2201void steepen(Array &array, float scale, int ir = 8);
2202
2204void steepen(Array &array, float scale, const Array *p_mask, int ir = 8);
2205
2234void steepen_convective(Array &array,
2235 float angle,
2236 int iterations = 1,
2237 int ir = 0,
2238 float dt = 0.1f);
2239
2241void steepen_convective(Array &array,
2242 float angle,
2243 const Array *p_mask,
2244 int iterations = 1,
2245 int ir = 0,
2246 float dt = 0.1f);
2247
2281void terrace(Array &array,
2282 std::uint32_t seed,
2283 int nlevels,
2284 float gain = 0.9f,
2285 float noise_ratio = 0.f,
2286 const Array *p_noise = nullptr,
2287 float vmin = 0.f,
2288 float vmax = -1.f);
2289
2330void terrace(Array &array,
2331 std::uint32_t seed,
2332 int nlevels,
2333 const Array *p_mask,
2334 float gain = 0.9f,
2335 float noise_ratio = 0.f,
2336 const Array *p_noise = nullptr,
2337 float vmin = 0.f,
2338 float vmax = -1.f);
2339
2340} // namespace hmap
2341
2342namespace hmap::gpu
2343{
2344
2368Array bilateral_filter(const Array &array,
2369 const Array &kernel2d,
2370 const Array &kernel1d,
2371 float kernel1d_value_scaling);
2372
2396
2398Array bilateral_filter(const Array &array,
2399 int ir,
2400 float kernel1d_value_scaling);
2401
2420void directional_blur(Array &array,
2421 float radius,
2422 const Array &angle,
2423 int steps = 32);
2424
2426void directional_blur(Array &array,
2427 float radius,
2428 const Array &angle,
2429 const Array *p_mask,
2430 int steps = 32);
2431
2433Array distance_shaper(const Array &array,
2434 float falloff = 0.05f,
2435 int directions = 8,
2436 float skew = 0.f,
2437 float angle = 0.f,
2440 float angular_jitter = 0.f,
2441 float falloff_jitter = 0.f,
2442 float threshold = 0.f,
2443 bool invert_input = false,
2444 bool invert_output = false,
2445 float mix_ratio = 1.f,
2446 std::uint32_t seed = 0,
2447 const Array *p_mask = nullptr,
2448 const Array *p_dx = nullptr,
2449 const Array *p_dy = nullptr);
2450
2452void expand(Array &array, int ir, int iterations = 1);
2453
2455void expand(Array &array, int ir, const Array *p_mask, int iterations = 1);
2456
2458void expand(Array &array, const Array &kernel, int iterations = 1);
2459
2461void expand(Array &array,
2462 const Array &kernel,
2463 const Array *p_mask,
2464 int iterations = 1);
2466void gamma_correction_local(Array &array,
2467 float gamma,
2468 int ir,
2469 float k = 0.1f,
2470 MinMaxKernel kernel_type = MinMaxKernel::DISK);
2471
2473void gamma_correction_local(Array &array,
2474 float gamma,
2475 int ir,
2476 const Array *p_mask,
2477 float k = 0.1f,
2478 MinMaxKernel kernel_type = MinMaxKernel::DISK);
2479
2515Array jagged(const Array &array,
2516 glm::vec2 kw,
2517 float amp = 0.1f,
2518 std::uint32_t seed = 0,
2519 glm::vec2 jitter = {0.5f, 0.5f},
2520 float gamma = 1.f,
2521 float angle = 0.f,
2522 const Array *p_mask = nullptr,
2523 const Array *p_noise_x = nullptr,
2524 const Array *p_noise_y = nullptr,
2525 const UvRect &uv_rect = UvRect::unit());
2526
2550Array jagged(const Array &array,
2551 float kw,
2552 float amp = 0.1f,
2553 std::uint32_t seed = 0,
2554 glm::vec2 jitter = {0.5f, 0.5f},
2555 float gamma = 1.f,
2556 float angle = 0.f,
2557 const Array *p_mask = nullptr,
2558 const Array *p_noise_x = nullptr,
2559 const Array *p_noise_y = nullptr,
2560 const UvRect &uv_rect = UvRect::unit());
2561
2599Array jagged_fbm(const Array &array,
2600 glm::vec2 kw,
2601 float amp = 0.1f,
2602 std::uint32_t seed = 0,
2603 int octaves = 8,
2604 float persistence = 0.5f,
2605 float lacunarity = 2.f,
2606 bool switch_kx_ky = false,
2607 glm::vec2 jitter = {0.5f, 0.5f},
2608 float gamma = 1.f,
2609 float angle = 0.f,
2610 const Array *p_mask = nullptr,
2611 const Array *p_noise_x = nullptr,
2612 const Array *p_noise_y = nullptr,
2613 const UvRect &uv_rect = UvRect::unit());
2614
2644Array jagged_fbm(const Array &array,
2645 float kw,
2646 float amp = 0.1f,
2647 std::uint32_t seed = 0,
2648 int octaves = 8,
2649 float persistence = 0.5f,
2650 float lacunarity = 2.f,
2651 bool switch_kx_ky = false,
2652 glm::vec2 jitter = {0.5f, 0.5f},
2653 float gamma = 1.f,
2654 float angle = 0.f,
2655 const Array *p_mask = nullptr,
2656 const Array *p_noise_x = nullptr,
2657 const Array *p_noise_y = nullptr,
2658 const UvRect &uv_rect = UvRect::unit());
2659
2661void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
2662
2664void laplace(Array &array,
2665 const Array *p_mask,
2666 float sigma = 0.2f,
2667 int iterations = 3);
2669Array mean_shift(const Array &array,
2670 int ir,
2671 float talus,
2672 int iterations = 1,
2673 bool talus_weighted = true);
2674
2675Array mean_shift(const Array &array,
2676 int ir,
2677 float talus,
2678 const Array *p_mask,
2679 int iterations = 1,
2680 bool talus_weighted = true);
2681
2683void median_3x3(Array &array);
2684
2686void median_3x3(Array &array, const Array *p_mask);
2688Array median_pseudo(const Array &array,
2689 int ir,
2690 MinMaxKernel kernel_type = MinMaxKernel::DISK);
2691
2693void normal_displacement(Array &array,
2694 float amount = 0.1f,
2695 int ir = 0,
2696 bool reverse = false);
2697
2699void normal_displacement(Array &array,
2700 const Array *p_mask,
2701 float amount = 0.1f,
2702 int ir = 0,
2703 bool reverse = false);
2705void plateau(Array &array,
2706 const Array *p_mask,
2707 int ir,
2708 float factor,
2709 MinMaxKernel kernel_type = MinMaxKernel::DISK);
2710
2712void plateau(Array &array,
2713 int ir,
2714 float factor,
2715 MinMaxKernel kernel_type = MinMaxKernel::DISK);
2716
2739Array project_talus_along_direction(const Array &array,
2740 const Array &talus,
2741 int direction = 0,
2742 float vmin = -FLT_MAX);
2743
2744Array project_talus_along_direction(const Array &array,
2745 const Array &talus,
2746 const Array *p_mask,
2747 int direction = 0,
2748 float vmin = -FLT_MAX);
2749
2770void recast_cliff(Array &array,
2771 float talus,
2772 int ir,
2773 float amplitude,
2774 float gain = 2.f,
2775 int iterations = 500,
2776 Array *p_cliff_mask = nullptr,
2777 int sync_interval = 0,
2778 const UvTile &region = UvTile::dummy(),
2779 ICommunicator &comm = SingleArrayComm::instance());
2780
2782void recast_cliff(Array &array,
2783 float talus,
2784 int ir,
2785 float amplitude,
2786 const Array *p_mask,
2787 float gain = 2.f,
2788 int iterations = 500,
2789 Array *p_cliff_mask = nullptr,
2790 int sync_interval = 0,
2791 const UvTile &region = UvTile::dummy(),
2792 ICommunicator &comm = SingleArrayComm::instance());
2793
2820
2823 Array &array,
2824 float talus,
2825 int ir,
2826 float amplitude,
2827 float angle,
2828 float gain = 2.f,
2829 int iterations = 500,
2830 Array *p_cliff_mask = nullptr,
2831 int sync_interval = 0,
2832 const UvTile &region = UvTile::dummy(),
2833 ICommunicator &comm = SingleArrayComm::instance());
2834
2837 Array &array,
2838 float talus,
2839 int ir,
2840 float amplitude,
2841 float angle,
2842 const Array *p_mask,
2843 float gain = 2.f,
2844 int iterations = 500,
2845 Array *p_cliff_mask = nullptr,
2846 int sync_interval = 0,
2847 const UvTile &region = UvTile::dummy(),
2848 ICommunicator &comm = SingleArrayComm::instance());
2849
2852 Array &array,
2853 float talus,
2854 int ir,
2855 float amplitude,
2856 const Array &angle,
2857 float gain = 2.f,
2858 int iterations = 500,
2859 Array *p_cliff_mask = nullptr,
2860 int sync_interval = 0,
2861 const UvTile &region = UvTile::dummy(),
2862 ICommunicator &comm = SingleArrayComm::instance());
2863
2866 Array &array,
2867 float talus,
2868 int ir,
2869 float amplitude,
2870 const Array &angle,
2871 const Array *p_mask,
2872 float gain = 2.f,
2873 int iterations = 500,
2874 Array *p_cliff_mask = nullptr,
2875 int sync_interval = 0,
2876 const UvTile &region = UvTile::dummy(),
2877 ICommunicator &comm = SingleArrayComm::instance());
2878
2880void ridge_accentuate(Array &array,
2881 float strength = 0.1f,
2882 int ir = 0,
2883 bool reverse = false);
2884
2886void ridge_accentuate(Array &array,
2887 const Array *p_mask,
2888 float strength = 0.1f,
2889 int ir = 0,
2890 bool reverse = false);
2891
2893void shrink(Array &array, int ir, int iterations = 1);
2894
2896void shrink(Array &array, int ir, const Array *p_mask, int iterations = 1);
2897
2899void shrink(Array &array, const Array &kernel, int iterations = 1);
2900
2902void shrink(Array &array,
2903 const Array &kernel,
2904 const Array *p_mask,
2905 int iterations = 1);
2906
2908void smooth_cpulse(Array &array,
2909 int ir,
2910 const Array *p_mask = nullptr,
2911 const UvTile &region = UvTile::dummy(),
2912 ICommunicator &comm = SingleArrayComm::instance());
2913
2915void smooth_cpulse_edge_removing(Array &array,
2916 float talus,
2917 float talus_width,
2918 int ir);
2919
2921void smooth_fill(Array &array,
2922 int ir,
2923 float k = 0.1f,
2924 Array *p_deposition_map = nullptr);
2925
2927void smooth_fill(Array &array,
2928 int ir,
2929 const Array *p_mask,
2930 float k = 0.1f,
2931 Array *p_deposition_map = nullptr);
2933void smooth_fill_holes(Array &array, int ir);
2934
2936void smooth_fill_holes(Array &array, int ir, const Array *p_mask);
2938void smooth_fill_smear_peaks(Array &array, int ir);
2939
2941void smooth_fill_smear_peaks(Array &array, int ir, const Array *p_mask);
2942
2961Array spectral_equalizer(const Array &array,
2962 const std::vector<float> &weights,
2963 int ir_min,
2964 int ir_max);
2965
2967Array spectral_equalizer(const Array &array,
2968 const std::vector<float> &weights,
2969 int ir_min,
2970 int ir_max,
2971 const Array *p_mask);
2972
2998Array voronoi_shrink(const Array &array,
2999 glm::vec2 kw,
3000 float shrink_factor = 0.8f,
3001 float fill_value = 0.f,
3002 std::uint32_t seed = 0,
3003 glm::vec2 jitter = {0.5f, 0.5f},
3004 float angle = 0.f,
3005 const Array *p_mask = nullptr,
3006 const Array *p_noise_x = nullptr,
3007 const Array *p_noise_y = nullptr,
3008 const UvRect &uv_rect = UvRect::unit());
3009
3033Array voronoi_shrink(const Array &array,
3034 float kw,
3035 float shrink_factor = 0.8f,
3036 float fill_value = 0.f,
3037 std::uint32_t seed = 0,
3038 glm::vec2 jitter = {0.5f, 0.5f},
3039 float angle = 0.f,
3040 const Array *p_mask = nullptr,
3041 const Array *p_noise_x = nullptr,
3042 const Array *p_noise_y = nullptr,
3043 const UvRect &uv_rect = UvRect::unit());
3044
3061Array voronoi_shrink(const Array &array,
3062 const Cloud &cloud,
3063 float shrink_factor = 0.8f,
3064 float fill_value = 0.f,
3065 const Array *p_mask = nullptr,
3066 const Array *p_noise_x = nullptr,
3067 const Array *p_noise_y = nullptr,
3068 const UvRect &uv_rect = UvRect::unit());
3069
3088Array voronoi_shrink(const Array &array,
3089 const std::vector<Point> &points,
3090 float shrink_factor = 0.8f,
3091 float fill_value = 0.f,
3092 const Array *p_mask = nullptr,
3093 const Array *p_noise_x = nullptr,
3094 const Array *p_noise_y = nullptr,
3095 const UvRect &uv_rect = UvRect::unit());
3096
3116Array voronoi_shrink(const Array &array,
3117 const std::vector<glm::vec2> &points,
3118 float shrink_factor = 0.8f,
3119 float fill_value = 0.f,
3120 const Array *p_mask = nullptr,
3121 const Array *p_noise_x = nullptr,
3122 const Array *p_noise_y = nullptr,
3123 const UvRect &uv_rect = UvRect::unit());
3124
3125} // 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:31
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:61
Abstract communicator interface providing MPI-style collective directives for single-source SPMD Arra...
Definition communicator_interface.hpp:60
A class to represent and manipulate 2D points that can carry a value.
Definition point.hpp:26
static SingleArrayComm & instance()
Definition communicator.cpp:78
Header file for kernel functions and utilities.
Definition array_blending.hpp:225
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:337
void laplace(Array &array, float sigma=0.2f, int iterations=3)
See hmap::laplace.
Definition filters_gpu.cpp:149
Array distance_shaper(const Array &array, float falloff=0.05f, int directions=8, float skew=0.f, float angle=0.f, DistanceMode mode=DistanceMode::PYRAMID, DistanceMethod method=DistanceMethod::RT, float angular_jitter=0.f, float falloff_jitter=0.f, float threshold=0.f, bool invert_input=false, bool invert_output=false, float mix_ratio=1.f, std::uint32_t seed=0, const Array *p_mask=nullptr, const Array *p_dx=nullptr, const Array *p_dy=nullptr)
See hmap::distance_shaper.
Definition distance_shaper.cpp:102
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:18
void expand(Array &array, int ir, int iterations=1)
See hmap::expand.
Definition filters_gpu.cpp:27
void smooth_fill_smear_peaks(Array &array, int ir)
See hmap::smooth_fill_smear_peaks.
Definition filters_gpu.cpp:655
Array jagged_fbm(const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, int octaves=8, float persistence=0.5f, float lacunarity=2.f, bool switch_kx_ky=false, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter to an ar...
Definition jagged.cpp:96
void smooth_cpulse_edge_removing(Array &array, float talus, float talus_width, int ir)
See hmap::smooth_cpulse_edge_removing.
Definition filters_gpu.cpp:587
void smooth_fill_holes(Array &array, int ir)
See hmap::smooth_fill_holes.
Definition filters_gpu.cpp:627
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:176
void shrink(Array &array, int ir, int iterations=1)
See hmap::shrink.
Definition filters_gpu.cpp:441
void gamma_correction_local(Array &array, float gamma, int ir, float k=0.1f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
See hmap::gamma_correction_local.
Definition filters_gpu.cpp:93
void recast_cliff(Array &array, float talus, int ir, float amplitude, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Transform heightmap to add cliffs where gradients are steep enough using Poisson gradient amplificati...
Definition recast_cliff.cpp:27
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:16
Array voronoi_shrink(const Array &array, glm::vec2 kw, float shrink_factor=0.8f, float fill_value=0.f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Apply a Voronoi shrinker filter to an input heightmap.
Definition voronoi_shrink.cpp:21
void recast_cliff_directional(Array &array, float talus, int ir, float amplitude, float angle, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Transform heightmap to add directional cliffs where gradients are steep enough using Poisson gradient...
Definition recast_cliff.cpp:166
void normal_displacement(Array &array, float amount=0.1f, int ir=0, bool reverse=false)
See hmap::normal_displacement.
Definition filters_gpu.cpp:260
void smooth_cpulse(Array &array, int ir, const Array *p_mask=nullptr, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
See hmap::smooth_cpulse.
Definition filters_gpu.cpp:514
Array jagged(const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Apply a Voronoi-based jagged bubble dome filter to an array.
Definition jagged.cpp:19
void smooth_fill(Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
See hmap::smooth_fill.
Definition filters_gpu.cpp:600
void plateau(Array &array, const Array *p_mask, int ir, float factor, MinMaxKernel kernel_type=MinMaxKernel::DISK)
See hmap::plateau.
Definition filters_gpu.cpp:296
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:15
Array median_pseudo(const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
See hmap::median_pseudo.
Definition filters_gpu.cpp:251
void median_3x3(Array &array)
See hmap::median_3x3.
Definition filters_gpu.cpp:228
void ridge_accentuate(Array &array, float strength=0.1f, int ir=0, bool reverse=false)
See hmap::ridge_accentuate.
Definition filters_gpu.cpp:405
Definition opencv.hpp:20
void smooth_cpulse(Array &array, int ir, const Array *p_mask=nullptr, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Apply filtering to the array using convolution with a cubic pulse kernel.
Definition filters.cpp:999
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:458
Array median_pseudo(const Array &array, int ir)
Computes a fast pseudo-median approximation of a local neighborhood in an array.
Definition filters.cpp:702
DistanceMode
Directional pattern mode for distance shaper.
Definition filters.hpp:37
@ ASTERISK
Star-shaped pattern with cut-ins between directions.
Definition filters.hpp:38
@ PYRAMID
Diamond/polyhedral pattern with flat planar facets.
Definition filters.hpp:39
void equalize(Array &array)
Apply histogram equalization to the array values.
Definition filters.cpp:39
void smooth_fill_holes(Array &array, int ir)
Apply smoothing to fill holes (elliptic concave surfaces).
Definition filters.cpp:1154
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, const UvRect &uv_rect=UvRect::unit())
Transform heightmap by adding "rock-like" features at higher slopes.
Definition recast.cpp:232
Array distance_shaper(const Array &array, float falloff=0.05f, int directions=8, float skew=0.f, float angle=0.f, DistanceMode mode=DistanceMode::PYRAMID, DistanceMethod method=DistanceMethod::RT, float angular_jitter=0.f, float falloff_jitter=0.f, float threshold=0.f, bool invert_input=false, bool invert_output=false, float mix_ratio=1.f, std::uint32_t seed=0, const Array *p_mask=nullptr, const Array *p_dx=nullptr, const Array *p_dy=nullptr)
Generates sloped, stratified terrain profiles from shapes and masks using directional distance fields...
Definition distance_shaper.cpp:237
void fold_periodic(Array &array, PhasorProfile phasor_profile, float vmin, float vmax, int iterations=3, float delta=0.f)
Apply a periodic "folding" filter to the array elements using a periodic phasor profile.
Definition filters.cpp:201
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:1306
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:169
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:173
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}, const UvRect &uv_rect=UvRect::unit())
Applies a primitive-based displacement to an array.
Definition bulkify.cpp:11
MinMaxKernel
Kernel footprint geometry for local minimum / maximum operations.
Definition local_metrics.hpp:22
@ DISK
Circular disk neighborhood.
Definition local_metrics.hpp:23
Array threshold(const Array &array, float x0, float x1)
Linear threshold.
Definition math.cpp:640
void steepen(Array &array, float scale, int ir=8)
Steepen (or flatten) the array map.
Definition filters.cpp:1234
void canyonize(Array &array, std::uint32_t seed=0, int nlevels=6, float convex_ratio=3.0f, float gamma_convex=3.0f, float gamma_concave=0.3f, float clamp_min_val=-std::numeric_limits< float >::infinity(), float k_smooth=0.1f, float noise_ratio=0.2f, const Array *p_noise=nullptr, float vmin=1.f, float vmax=0.f)
Applies a canyonize filter to a heightmap.
Definition canyonize.cpp:23
void make_binary(Array &array, float threshold=0.f)
Convert array values to binary using a threshold.
Definition filters.cpp:538
void smooth_gaussian(Array &array, int ir)
Apply Gaussian filtering to the array.
Definition filters.cpp:1080
void falloff(Array &array, float strength=1.f, DistanceFunction dist_fct=DistanceFunction::EUCLIDIAN, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit())
Applies a falloff effect to the input array based on distance.
Definition boundary.cpp:91
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:777
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:946
void sharpen_cone(Array &array, int ir, float intensity=0.5f)
Apply a sharpening filter based on a smooth cone filter.
Definition filters.cpp:886
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:410
DistanceMethod
Method used to calculate distance.
Definition filters.hpp:46
@ CLASSIC
Standard Euclidean distance transform.
Definition filters.hpp:48
@ RT
Real-time directional slope projection.
Definition filters.hpp:47
PhasorProfile
Phasor angular profile type.
Definition profiles.hpp:38
@ PP_COSINE_STD
Definition profiles.hpp:42
void recurve_exp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "sharp exponential-shape" curve.
Definition recurve.cpp:85
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:15
void sharpen(Array &array, float ratio=1.f)
Apply a sharpening filter based on the Laplace operator.
Definition filters.cpp:862
Cloud scale(const Cloud &cloud, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f})
Scales the point coordinates in a cloud relative to a center point.
Definition cloud_functions.cpp:163
void smooth_flat(Array &array, int ir)
Applies a smoothing average filter to the given 2D array in both dimensions.
Definition filters.cpp:1065
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:495
Array quantize(const Array &array, int nlevels, float vmin, float vmax)
Quantize array values into discrete levels.
Definition dequantize.cpp:33
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:1255
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:578
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:550
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:19
void median_3x3(Array &array, const Array *p_mask)
Apply a 3x3 median filter to the input array.
Definition filters.cpp:694
UvTile UvTile
Definition communicator_interface.hpp:49
void ridge_accentuate(Array &array, float strength=0.1f, int ir=0, bool reverse=false)
Accentuate ridges by gradient-directed resampling along the normal direction.
Definition ridge_accentuate.cpp:15
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:100
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:19
void smoothstep_local(Array &array, int ir)
Applies a localized smoothstep operation to the provided array.
Definition filters.cpp:1208
void recurve_s(Array &array)
Apply a curve adjustment filter using a smooth "S-shape" curve.
Definition recurve.cpp:127
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:1052
void saturate_percentile(Array &array, float percentile_low, float percentile_high, float k=0.f)
Saturate values based on percentile range.
Definition recurve.cpp:205
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
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:710
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:251
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:785
void gamma_correction(Array &array, float gamma, const Array *p_mask)
Apply gamma correction to the input array.
Definition filters.cpp:271
void smooth_cone(Array &array, int ir)
Apply a convolution filter with a cone kernel to smooth the array.
Definition filters.cpp:963
void recast_sag(Array &array, float vref, float k)
Transform heightmap to give a "cliff" like appearance.
Definition recast.cpp:305
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:34
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:207
void shrink(Array &array, int ir, int iterations=1)
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
Definition filters.cpp:903
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:279
void recast_billow(Array &array, float vref, float k)
Transform heightmap to give a "billow" like appearance.
Definition recast.cpp:24
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:328
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:133
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:87
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:1119
void recurve_kura(Array &array, float a, float b)
Apply a curve adjustment filter using Kumaraswamy's cumulative distribution function (CDF).
Definition recurve.cpp:106
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:107
void recurve_bexp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "bumpy exponential-shape" curve.
Definition recurve.cpp:64
void smooth_fill_smear_peaks(Array &array, int ir)
Apply smoothing to smear peaks (elliptic convex surfaces).
Definition filters.cpp:1180
void recurve_smoothstep_rational(Array &array, float n)
Apply a curve adjustment filter using an nth-order smoothstep curve.
Definition recurve.cpp:147
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:146
Definition virtual_array.hpp:54
Axis-aligned rectangle in normalized [0, 1]^2 domain/UV space.
Definition uv_rect.hpp:30
static constexpr UvRect unit()
Definition uv_rect.hpp:46
Describes an Array tile's position within the normalized [0, 1]^2 UV domain and global index grid.
Definition uv_tile.hpp:46
static const UvTile & dummy()
Definition uv_tile.cpp:37
Definition virtual_array.hpp:65
Normalized UV-domain tile descriptor for single-source SPMD Array algorithms and VirtualArray dispatc...