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
43Array bulkify(const Array &z,
44 const PrimitiveType &primitive_type,
45 float amp = 1.f,
46 const Array *p_noise_x = nullptr,
47 const Array *p_noise_y = nullptr,
48 glm::vec2 center = {0.5f, 0.5f},
49 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
50
79Array diffusion_retargeting(const Array &array_before,
80 const Array &array_after,
81 int ir);
82
83Array diffusion_retargeting(const Array &array_before,
84 const Array &array_after,
85 const Array &mask,
86 int iterations);
87
129void directional_blur(Array &array,
130 int ir,
131 float angle,
132 float intensity,
133 float stretch = 1.f,
134 float spread = 1.f);
135
159void directional_blur(Array &array,
160 int ir,
161 const Array &angle,
162 float intensity,
163 float stretch = 1.f,
164 float spread = 1.f);
165
174void equalize(Array &array);
175
189void equalize(Array &array, const Array *p_mask);
190
212void expand(Array &array, int ir, const Array *p_mask, int iterations = 1);
213
226void expand(Array &array, int ir, int iterations = 1);
227
239void expand(Array &array, const Array &kernel, int iterations = 1);
240
255void expand(Array &array,
256 const Array &kernel,
257 const Array *p_mask,
258 int iterations = 1);
259
288void expand_directional(Array &array,
289 int ir,
290 float angle,
291 float aspect_ratio,
292 float anisotropy = 1.f,
293 const Array *p_mask = nullptr);
294
313void expand_talus(Array &z,
314 const Array &mask,
315 float talus,
316 uint seed,
317 int ir = 1,
318 float noise_ratio = 0.2f);
319
346Array faceted(const Array &array,
347 int neighborhood = 0,
348 const Array *p_noise_x = nullptr,
349 const Array *p_noise_y = nullptr);
350
385void fill_talus(Array &z,
386 float talus,
387 uint seed,
388 int ir = 1,
389 float noise_ratio = 0.2f,
390 const Array *p_seed_mask = nullptr);
391
392void fill_talus(Array &z,
393 const Array &talus,
394 uint seed,
395 int ir = 1,
396 float noise_ratio = 0.2f,
397 const Array *p_seed_mask = nullptr);
398
436void fill_talus_fast(Array &z,
437 glm::ivec2 shape_coarse,
438 float talus,
439 uint seed,
440 int ir = 1,
441 float noise_ratio = 0.2f);
442
471void fold(Array &array,
472 float vmin,
473 float vmax,
474 int iterations = 3,
475 float k = 0.05f);
476
494void fold(Array &array, int iterations = 3, float k = 0.05f);
495
519void gain(Array &array, float factor, const Array *p_mask);
520
533void gain(Array &array, float factor);
534
561void gamma_correction(Array &array, float gamma, const Array *p_mask);
562
576void gamma_correction(Array &array, float gamma);
577
606void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
607
631void gamma_correction_local(Array &array,
632 float gamma,
633 int ir,
634 const Array *p_mask,
635 float k = 0.1f);
636
658void kuwahara(Array &array, int ir, float mix_ratio = 1.f);
659
688void kuwahara(Array &array, int ir, const Array *p_mask, float mix_ratio = 1.f);
689
719void laplace(Array &array, float sigma = 0.125f, int iterations = 3);
720
742void laplace(Array &array,
743 const Array *p_mask,
744 float sigma = 0.125f,
745 int iterations = 3);
746
761void laplace1d(std::vector<float> &v, float sigma = 0.5f, int iterations = 1);
762
789void laplace_edge_preserving(Array &array,
790 float talus,
791 float sigma = 0.2f,
792 int iterations = 3);
793
819void laplace_edge_preserving(Array &array,
820 float talus,
821 const Array *p_mask,
822 float sigma = 0.2f,
823 int iterations = 3);
824
848void low_pass_high_order(Array &array, int order = 9, float sigma = 1.f);
849
863void make_binary(Array &array, float threshold = 0.f);
864
887Array maximum_local(const Array &array, int ir);
888
911Array maximum_local_disk(const Array &array, int ir);
912
933void match_histogram(Array &array, const Array &array_reference);
934
963Array mean_shift(const Array &array,
964 int ir,
965 float talus,
966 int iterations = 1,
967 bool talus_weighted = true);
968
969Array mean_shift(const Array &array,
970 int ir,
971 float talus,
972 const Array *p_mask,
973 int iterations = 1,
974 bool talus_weighted = true);
975
995void median_3x3(Array &array, const Array *p_mask);
996
1008void median_3x3(Array &array);
1009
1043Array median_pseudo(const Array &array, int ir);
1044
1067Array minimum_local(const Array &array, int ir);
1068
1091Array minimum_local_disk(const Array &array, int ir);
1092
1117void normal_displacement(Array &array,
1118 float amount = 0.1f,
1119 int ir = 0,
1120 bool reverse = false);
1121
1122void normal_displacement(Array &array,
1123 const Array *p_mask,
1124 float amount = 0.1f,
1125 int ir = 0,
1126 bool reverse = false);
1127
1152void plateau(Array &array, const Array *p_mask, int ir, float factor);
1153
1154void plateau(Array &array, int ir, float factor);
1177void recast_billow(Array &array, float vref, float k);
1178
1206void recast_canyon(Array &array, const Array &vcut, float gamma = 4.f);
1207
1208void recast_canyon(Array &array,
1209 const Array &vcut,
1210 const Array *p_mask,
1211 float gamma = 4.f);
1212
1213void recast_canyon(Array &array,
1214 float vcut,
1215 const Array *p_mask,
1216 float gamma = 4.f,
1217 const Array *p_noise = nullptr);
1218
1219void recast_canyon(Array &array,
1220 float vcut,
1221 float gamma = 4.f,
1222 const Array *p_noise = nullptr);
1223
1253void recast_cliff(Array &array,
1254 float talus,
1255 int ir,
1256 float amplitude,
1257 float gain = 2.f);
1258
1259void recast_cliff(Array &array,
1260 float talus,
1261 int ir,
1262 float amplitude,
1263 const Array *p_mask,
1264 float gain = 2.f);
1265
1298void recast_cliff_directional(Array &array,
1299 float talus,
1300 int ir,
1301 float amplitude,
1302 float angle,
1303 float gain = 2.f);
1304
1305void recast_cliff_directional(Array &array,
1306 float talus,
1307 int ir,
1308 float amplitude,
1309 float angle,
1310 const Array *p_mask,
1311 float gain = 2.f);
1312
1313void recast_cracks(Array &array,
1314 float cut_min = 0.05f,
1315 float cut_max = 0.5f,
1316 float k_smoothing = 0.01f,
1317 float vmin = 0.f,
1318 float vmax = -1.f);
1319
1356void recast_escarpment(Array &array,
1357 int ir = 16,
1358 float ratio = 0.1f,
1359 float scale = 1.f,
1360 bool reverse = false,
1361 bool transpose_effect = false,
1362 float global_scaling = 0.f);
1363
1402void recast_escarpment(Array &array,
1403 const Array *p_mask,
1404 int ir = 16,
1405 float ratio = 0.1f,
1406 float scale = 1.f,
1407 bool reverse = false,
1408 bool transpose_effect = false,
1409 float global_scaling = 0.f);
1410
1442void recast_peak(Array &array, int ir, float gamma = 2.f, float k = 0.1f);
1443
1444void recast_peak(Array &array,
1445 int ir,
1446 const Array *p_mask,
1447 float gamma = 2.f,
1448 float k = 0.1f);
1449
1494void recast_rocky_slopes(Array &array,
1495 float talus,
1496 int ir,
1497 float amplitude,
1498 uint seed,
1499 float kw,
1500 float gamma = 0.5f,
1501 const Array *p_noise = nullptr,
1502 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
1503
1504void recast_rocky_slopes(Array &array,
1505 float talus,
1506 int ir,
1507 float amplitude,
1508 uint seed,
1509 float kw,
1510 const Array *p_mask,
1511 float gamma = 0.5f,
1512 const Array *p_noise = nullptr,
1513 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
1514
1542void recast_sag(Array &array, float vref, float k);
1543
1544void recast_sag(Array &array,
1545 float vref,
1546 float k,
1547 const Array *p_mask);
1548
1574void recurve(Array &array,
1575 const std::vector<float> &t,
1576 const std::vector<float> &v);
1577
1578void recurve(Array &array,
1579 const std::vector<float> &t,
1580 const std::vector<float> &v,
1581 const Array *p_mask);
1582
1610void recurve_bexp(Array &array, float tau = 0.5f);
1611
1613 const Array *p_mask,
1614 float tau = 0.5f);
1615
1643void recurve_exp(Array &array, float tau = 0.5f);
1644
1645void recurve_exp(Array &array,
1646 const Array *p_mask,
1647 float tau = 0.5f);
1648
1674void recurve_kura(Array &array, float a, float b);
1675
1676void recurve_kura(Array &array,
1677 float a,
1678 float b,
1679 const Array *p_mask);
1680
1702void recurve_s(Array &array);
1703
1704void recurve_s(Array &array, const Array *p_mask);
1705
1730void recurve_smoothstep_rational(Array &array, float n);
1731
1733 float n,
1734 const Array *p_mask);
1735
1764void reverse_above_theshold(Array &array,
1765 const Array &threshold,
1766 float scaling = 1.f,
1767 float transition_extent = 0.f);
1768
1769void reverse_above_theshold(Array &array,
1770 float threshold,
1771 float scaling = 1.f,
1772 float transition_extent = 0.f);
1773
1774void reverse_above_theshold(Array &array,
1775 const Array &threshold,
1776 const Array *p_mask,
1777 float scaling = 1.f,
1778 float transition_extent = 0.f);
1779
1780void reverse_above_theshold(Array &array,
1781 float threshold,
1782 const Array *p_mask,
1783 float scaling = 1.f,
1784 float transition_extent = 0.f);
1785
1806void saturate(Array &array,
1807 float vmin,
1808 float vmax,
1809 float from_min,
1810 float from_max,
1811 float k = 0.f);
1812
1813void saturate(Array &array, float vmin, float vmax, float k = 0.f);
1814
1839void sharpen(Array &array, float ratio = 1.f);
1840
1841void sharpen(Array &array,
1842 const Array *p_mask,
1843 float ratio = 1.f);
1844
1870void sharpen_cone(Array &array, int ir, float intensity = 0.5f);
1871
1872void sharpen_cone(Array &array,
1873 const Array *p_mask,
1874 int ir,
1875 float scale = 0.5f);
1876
1905void shrink(Array &array, int ir, int iterations = 1);
1906void shrink(Array &array,
1907 int ir,
1908 const Array *p_mask,
1909 int iterations = 1);
1910void shrink(Array &array,
1911 const Array &kernel,
1912 int iterations = 1);
1913void shrink(Array &array,
1914 const Array &kernel,
1915 const Array *p_mask,
1916 int iterations = 1);
1917
1947void shrink_directional(Array &array,
1948 int ir,
1949 float angle,
1950 float aspect_ratio,
1951 float anisotropy = 1.f,
1952 const Array *p_mask = nullptr);
1953
1974void smooth_cone(Array &array, int ir);
1975void smooth_cone(Array &array, int ir, const Array *p_mask);
1976
2002void smooth_cpulse(Array &array, int ir);
2003void smooth_cpulse(Array &array, int ir, const Array *p_mask);
2004
2025 float talus,
2026 float talus_width,
2027 int ir);
2028
2042void smooth_flat(Array &array, int ir);
2043
2066void smooth_gaussian(Array &array, int ir);
2067void smooth_gaussian(Array &array, int ir, const Array *p_mask);
2100void smooth_fill(Array &array,
2101 int ir,
2102 float k = 0.1f,
2103 Array *p_deposition_map = nullptr);
2104
2105void smooth_fill(Array &array,
2106 int ir,
2107 const Array *p_mask,
2108 float k = 0.1f,
2109 Array *p_deposition_map = nullptr);
2110
2134void smooth_fill_holes(Array &array, int ir);
2135void smooth_fill_holes(Array &array,
2136 int ir,
2137 const Array *p_mask);
2138
2162void smooth_fill_smear_peaks(Array &array, int ir);
2163void smooth_fill_smear_peaks(Array &array,
2164 int ir,
2165 const Array *p_mask);
2166
2183void smoothstep_local(Array &array, int ir);
2184
2205void smoothstep_local(Array &array, int ir, const Array *p_mask);
2206
2232void steepen(Array &array, float scale, int ir = 8);
2233void steepen(Array &array,
2234 float scale,
2235 const Array *p_mask,
2236 int ir = 8);
2237
2266void steepen_convective(Array &array,
2267 float angle,
2268 int iterations = 1,
2269 int ir = 0,
2270 float dt = 0.1f);
2271
2272void steepen_convective(Array &array,
2273 float angle,
2274 const Array *p_mask,
2275 int iterations = 1,
2276 int ir = 0,
2277 float dt = 0.1f);
2278
2312void terrace(Array &array,
2313 uint seed,
2314 int nlevels,
2315 float gain = 0.9f,
2316 float noise_ratio = 0.f,
2317 const Array *p_noise = nullptr,
2318 float vmin = 0.f,
2319 float vmax = -1.f);
2320
2361void terrace(Array &array,
2362 uint seed,
2363 int nlevels,
2364 const Array *p_mask,
2365 float gain = 0.9f,
2366 float noise_ratio = 0.f,
2367 const Array *p_noise = nullptr,
2368 float vmin = 0.f,
2369 float vmax = -1.f);
2370
2395Array tessellate(Array &array,
2396 uint seed,
2397 float node_density = 0.001f,
2398 const Array *p_weight = nullptr);
2399
2436void wrinkle(Array &array,
2437 float wrinkle_amplitude,
2438 const Array *p_mask,
2439 float wrinkle_angle = 0.f,
2440 float displacement_amplitude = 1.f,
2441 int ir = 0,
2442 float kw = 2.f,
2443 uint seed = 1,
2444 int octaves = 8,
2445 float weight = 0.7f,
2446 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
2447
2448void wrinkle(Array &array,
2449 float wrinkle_amplitude,
2450 float wrinkle_angle = 0.f,
2451 float displacement_amplitude = 1.f,
2452 int ir = 0,
2453 float kw = 2.f,
2454 uint seed = 1,
2455 int octaves = 8,
2456 float weight = 0.7f,
2457 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
2458
2459} // namespace hmap
2460
2461namespace hmap::gpu
2462{
2463
2487Array bilateral_filter(const Array &array,
2488 const Array &kernel2d,
2489 const Array &kernel1d,
2490 float kernel1d_value_scaling);
2491
2515Array bilateral_filter(const Array &array,
2516 int ir,
2517 float kernel1d_value_scaling);
2518
2520void expand(Array &array, int ir, int iterations = 1);
2521void expand(Array &array,
2522 int ir,
2523 const Array *p_mask,
2524 int iterations = 1);
2525void expand(Array &array,
2526 const Array &kernel,
2527 int iterations = 1);
2528void expand(Array &array,
2529 const Array &kernel,
2530 const Array *p_mask,
2531 int iterations = 1);
2532
2534void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
2535void gamma_correction_local(Array &array,
2536 float gamma,
2537 int ir,
2538 const Array *p_mask,
2539 float k = 0.1f);
2540
2542void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
2543void laplace(Array &array,
2544 const Array *p_mask,
2545 float sigma = 0.2f,
2546 int iterations = 3);
2547
2549Array maximum_local(const Array &array, int ir);
2550
2552Array maximum_local_disk(const Array &array, int ir);
2553
2555Array mean_shift(const Array &array,
2556 int ir,
2557 float talus,
2558 int iterations = 1,
2559 bool talus_weighted = true);
2560
2561Array mean_shift(const Array &array,
2562 int ir,
2563 float talus,
2564 const Array *p_mask,
2565 int iterations = 1,
2566 bool talus_weighted = true);
2567
2569void median_3x3(Array &array);
2570void median_3x3(Array &array, const Array *p_mask);
2571
2573Array median_pseudo(const Array &array, int ir);
2574
2576Array minimum_local(const Array &array, int ir);
2577
2579Array minimum_local_disk(const Array &array, int ir);
2580
2582void normal_displacement(Array &array,
2583 float amount = 0.1f,
2584 int ir = 0,
2585 bool reverse = false);
2586void normal_displacement(Array &array,
2587 const Array *p_mask,
2588 float amount = 0.1f,
2589 int ir = 0,
2590 bool reverse = false);
2591
2593void plateau(Array &array, const Array *p_mask, int ir, float factor);
2594void plateau(Array &array, int ir, float factor);
2595
2618Array project_talus_along_direction(const Array &array,
2619 float talus,
2620 int direction = 0);
2621
2622Array project_talus_along_direction(const Array &array,
2623 float talus,
2624 const Array *p_mask,
2625 int direction = 0);
2626
2628void shrink(Array &array, int ir, int iterations = 1);
2629void shrink(Array &array,
2630 int ir,
2631 const Array *p_mask,
2632 int iterations = 1);
2633void shrink(Array &array,
2634 const Array &kernel,
2635 int iterations = 1);
2636void shrink(Array &array,
2637 const Array &kernel,
2638 const Array *p_mask,
2639 int iterations = 1);
2640
2642void smooth_cpulse(Array &array, int ir);
2643
2645void smooth_cpulse(Array &array, int ir, const Array *p_mask);
2646
2648void smooth_cpulse_edge_removing(Array &array,
2649 float talus,
2650 float talus_width,
2651 int ir);
2652
2654void smooth_fill(Array &array,
2655 int ir,
2656 float k = 0.1f,
2657 Array *p_deposition_map = nullptr);
2658void smooth_fill(Array &array,
2659 int ir,
2660 const Array *p_mask,
2661 float k = 0.1f,
2662 Array *p_deposition_map = nullptr);
2663
2665void smooth_fill_holes(Array &array, int ir);
2666void smooth_fill_holes(Array &array,
2667 int ir,
2668 const Array *p_mask);
2669
2671void smooth_fill_smear_peaks(Array &array, int ir);
2672void smooth_fill_smear_peaks(Array &array,
2673 int ir,
2674 const Array *p_mask);
2675
2676} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
unsigned int uint
Definition array.hpp:14
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Definition blending.hpp:186
Array minimum_local_disk(const Array &array, int ir)
See hmap::minimum_local_disk.
Definition filters_gpu.cpp:301
Array project_talus_along_direction(const Array &array, float talus, int direction=0)
Projects array values along a given direction using talus attenuation.
Definition filters_gpu.cpp:392
void laplace(Array &array, float sigma=0.2f, int iterations=3)
See hmap::laplace.
Definition filters_gpu.cpp:144
Array maximum_local(const Array &array, int ir)
See hmap::maximum_local.
Definition filters_gpu.cpp:183
Array median_pseudo(const Array &array, int ir)
See hmap::median_pseudo.
Definition filters_gpu.cpp:289
void expand(Array &array, int ir, int iterations=1)
See hmap::expand.
Definition filters_gpu.cpp:16
void smooth_fill_smear_peaks(Array &array, int ir)
See hmap::smooth_fill_smear_peaks.
Definition filters_gpu.cpp:681
void smooth_cpulse_edge_removing(Array &array, float talus, float talus_width, int ir)
See hmap::smooth_cpulse_edge_removing.
Definition filters_gpu.cpp:618
void smooth_fill_holes(Array &array, int ir)
See hmap::smooth_fill_holes.
Definition filters_gpu.cpp:653
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:214
void shrink(Array &array, int ir, int iterations=1)
See hmap::shrink.
Definition filters_gpu.cpp:452
void gamma_correction_local(Array &array, float gamma, int ir, float k=0.1f)
See hmap::gamma_correction_local.
Definition filters_gpu.cpp:95
void smooth_cpulse(Array &array, int ir)
See hmap::smooth_cpulse.
Definition filters_gpu.cpp:546
void normal_displacement(Array &array, float amount=0.1f, int ir=0, bool reverse=false)
See hmap::normal_displacement.
Definition filters_gpu.cpp:309
void smooth_fill(Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
See hmap::smooth_fill.
Definition filters_gpu.cpp:629
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:9
Array maximum_local_disk(const Array &array, int ir)
See hmap::maximum_local_disk.
Definition filters_gpu.cpp:206
void plateau(Array &array, const Array *p_mask, int ir, float factor)
See hmap::plateau.
Definition filters_gpu.cpp:359
void median_3x3(Array &array)
See hmap::median_3x3.
Definition filters_gpu.cpp:264
Array minimum_local(const Array &array, int ir)
See hmap::minimum_local.
Definition filters_gpu.cpp:296
Definition algebra.hpp:23
void expand_talus(Array &z, const Array &mask, float talus, uint 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 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:379
Array median_pseudo(const Array &array, int ir)
Computes a fast pseudo-median approximation of a local neighborhood in an array.
Definition filters.cpp:599
void equalize(Array &array)
Apply histogram equalization to the array values.
Definition filters.cpp:30
void smooth_fill_holes(Array &array, int ir)
Apply smoothing to fill holes (elliptic concave surfaces).
Definition filters.cpp:1030
void directional_blur(Array &array, int ir, float angle, float intensity, float stretch=1.f, float spread=1.f)
Applies a directional blur to a 2D array based on a spatially varying angle field.
Definition directional_blur.cpp:55
Array maximum_local_disk(const Array &array, int ir)
Return the local maxima based on a maximum filter using a disk kernel.
Definition range.cpp:301
void fill_talus_fast(Array &z, glm::ivec2 shape_coarse, float talus, uint seed, int ir=1, float noise_ratio=0.2f)
Fill terrain values with a given downslope talus, optimized using a coarse mesh for faster computatio...
Definition fill_talus.cpp:107
Array minimum_local_disk(const Array &array, int ir)
Return the local minima based on a maximum filter using a disk kernel.
Definition range.cpp:385
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:159
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:178
void wrinkle(Array &array, float wrinkle_amplitude, const Array *p_mask, float wrinkle_angle=0.f, float displacement_amplitude=1.f, int ir=0, float kw=2.f, uint seed=1, int octaves=8, float weight=0.7f, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Apply wrinkle effect to the array, creating wrinkled or bumpy features.
Definition filters.cpp:1308
void steepen(Array &array, float scale, int ir=8)
Steepen (or flatten) the array map.
Definition filters.cpp:1114
Array tessellate(Array &array, uint seed, float node_density=0.001f, const Array *p_weight=nullptr)
Apply tessellation to the array with random node placement.
Definition tesselate.cpp:18
void make_binary(Array &array, float threshold=0.f)
Convert array values to binary using a threshold.
Definition filters.cpp:456
void smooth_gaussian(Array &array, int ir)
Apply Gaussian filtering to the array.
Definition filters.cpp:955
void fill_talus(Array &z, float talus, uint 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:97
Array maximum_local(const Array &array, int ir)
Return the local maxima based on a maximum filter with a square kernel.
Definition range.cpp:264
PrimitiveType
Defines the primitive shape used for synthesis.
Definition primitives.hpp:53
void plateau(Array &array, const Array *p_mask, int ir, float factor)
Apply a plateau-shape filter to the input array.
Definition filters.cpp:670
void terrace(Array &array, uint 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:1187
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:96
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:841
void sharpen_cone(Array &array, int ir, float intensity=0.5f)
Apply a sharpening filter based on a smooth cone filter.
Definition filters.cpp:779
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:331
void recurve_exp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "sharp exponential-shape" curve.
Definition recurve.cpp:76
void sharpen(Array &array, float ratio=1.f)
Apply a sharpening filter based on the Laplace operator.
Definition filters.cpp:753
void smooth_flat(Array &array, int ir)
Applies a smoothing average filter to the given 2D array in both dimensions.
Definition filters.cpp:942
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:415
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:1137
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:475
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:466
void median_3x3(Array &array, const Array *p_mask)
Apply a 3x3 median filter to the input array.
Definition filters.cpp:587
void smooth_cpulse(Array &array, int ir)
Apply filtering to the array using convolution with a cubic pulse kernel.
Definition filters.cpp:893
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:20
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:1086
void recurve_s(Array &array)
Apply a curve adjustment filter using a smooth "S-shape" curve.
Definition recurve.cpp:126
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:931
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:42
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:606
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:189
Array diffusion_retargeting(const Array &array_before, const Array &array_after, int ir)
Applies diffusion retargeting by detecting local maxima and adjusting based on the difference between...
Definition diffusion_retargeting.cpp:17
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:682
void gamma_correction(Array &array, float gamma, const Array *p_mask)
Apply gamma correction to the input array.
Definition filters.cpp:211
void smooth_cone(Array &array, int ir)
Apply a convolution filter with a cone kernel to smooth the array.
Definition filters.cpp:855
void recast_sag(Array &array, float vref, float k)
Transform heightmap to give a "cliff" like appearance.
Definition recast.cpp:412
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:32
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:308
void shrink(Array &array, int ir, int iterations=1)
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
Definition filters.cpp:798
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:146
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:223
Array faceted(const Array &array, int neighborhood=0, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr)
Generate a faceted heightmap that retains the main features of the input heightmap.
Definition faceted.cpp:17
void recast_billow(Array &array, float vref, float k)
Transform heightmap to give a "billow" like appearance.
Definition recast.cpp:22
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:272
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:231
Array minimum_local(const Array &array, int ir)
Return the local minima based on a maximum filter with a square kernel.
Definition range.cpp:380
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:79
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})
Definition bulkify.cpp:11
void recast_canyon(Array &array, const Array &vcut, float gamma=4.f)
Transform heightmap to give a "canyon" like appearance.
Definition recast.cpp:27
void recast_rocky_slopes(Array &array, float talus, int ir, float amplitude, uint 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:333
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:995
void recurve_kura(Array &array, float a, float b)
Apply a curve adjustment filter using Kumaraswamy's cumulative distribution function (CDF).
Definition recurve.cpp:101
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:207
void recurve_bexp(Array &array, float tau=0.5f)
Apply a curve adjustment filter using a "bumpy exponential-shape" curve.
Definition recurve.cpp:51
void smooth_fill_smear_peaks(Array &array, int ir)
Apply smoothing to smear peaks (elliptic convex surfaces).
Definition filters.cpp:1058
void recurve_smoothstep_rational(Array &array, float n)
Apply a curve adjustment filter using an nth-order smoothstep curve.
Definition recurve.cpp:150
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:140
Core procedural primitives for heightmap generation, including noise functions (Perlin,...