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 Vec2<float> center = {0.5f, 0.5f},
49 Vec4<float> 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
295void expand_talus(Array &z,
296 const Array &mask,
297 float talus,
298 uint seed,
299 float noise_ratio = 0.2f);
300
327Array faceted(const Array &array,
328 int neighborhood = 0,
329 const Array *p_noise_x = nullptr,
330 const Array *p_noise_y = nullptr);
331
363void fill_talus(Array &z, float talus, uint seed, float noise_ratio = 0.2f);
364
402void fill_talus_fast(Array &z,
403 Vec2<int> shape_coarse,
404 float talus,
405 uint seed,
406 float noise_ratio = 0.2f);
407
436void fold(Array &array,
437 float vmin,
438 float vmax,
439 int iterations = 3,
440 float k = 0.05f);
441
459void fold(Array &array, int iterations = 3, float k = 0.05f);
460
484void gain(Array &array, float factor, const Array *p_mask);
485
498void gain(Array &array, float factor);
499
526void gamma_correction(Array &array, float gamma, const Array *p_mask);
527
541void gamma_correction(Array &array, float gamma);
542
571void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
572
596void gamma_correction_local(Array &array,
597 float gamma,
598 int ir,
599 const Array *p_mask,
600 float k = 0.1f);
601
623void kuwahara(Array &array, int ir, float mix_ratio = 1.f);
624
653void kuwahara(Array &array, int ir, const Array *p_mask, float mix_ratio = 1.f);
654
684void laplace(Array &array, float sigma = 0.125f, int iterations = 3);
685
707void laplace(Array &array,
708 const Array *p_mask,
709 float sigma = 0.125f,
710 int iterations = 3);
711
726void laplace1d(std::vector<float> &v, float sigma = 0.5f, int iterations = 1);
727
754void laplace_edge_preserving(Array &array,
755 float talus,
756 float sigma = 0.2f,
757 int iterations = 3);
758
784void laplace_edge_preserving(Array &array,
785 float talus,
786 const Array *p_mask,
787 float sigma = 0.2f,
788 int iterations = 3);
789
813void low_pass_high_order(Array &array, int order = 9, float sigma = 1.f);
814
828void make_binary(Array &array, float threshold = 0.f);
829
852Array maximum_local(const Array &array, int ir);
853
876Array maximum_local_disk(const Array &array, int ir);
877
898void match_histogram(Array &array, const Array &array_reference);
899
928Array mean_shift(const Array &array,
929 int ir,
930 float talus,
931 int iterations = 1,
932 bool talus_weighted = true);
933
934Array mean_shift(const Array &array,
935 int ir,
936 float talus,
937 const Array *p_mask,
938 int iterations = 1,
939 bool talus_weighted = true);
940
960void median_3x3(Array &array, const Array *p_mask);
961
973void median_3x3(Array &array);
974
1008Array median_pseudo(const Array &array, int ir);
1009
1032Array minimum_local(const Array &array, int ir);
1033
1056Array minimum_local_disk(const Array &array, int ir);
1057
1082void normal_displacement(Array &array,
1083 float amount = 0.1f,
1084 int ir = 0,
1085 bool reverse = false);
1086
1087void normal_displacement(Array &array,
1088 const Array *p_mask,
1089 float amount = 0.1f,
1090 int ir = 0,
1091 bool reverse = false);
1092
1117void plateau(Array &array, const Array *p_mask, int ir, float factor);
1118
1119void plateau(Array &array, int ir, float factor);
1142void recast_billow(Array &array, float vref, float k);
1143
1171void recast_canyon(Array &array, const Array &vcut, float gamma = 4.f);
1172
1173void recast_canyon(Array &array,
1174 const Array &vcut,
1175 const Array *p_mask,
1176 float gamma = 4.f);
1177
1178void recast_canyon(Array &array,
1179 float vcut,
1180 const Array *p_mask,
1181 float gamma = 4.f,
1182 const Array *p_noise = nullptr);
1183
1184void recast_canyon(Array &array,
1185 float vcut,
1186 float gamma = 4.f,
1187 const Array *p_noise = nullptr);
1188
1218void recast_cliff(Array &array,
1219 float talus,
1220 int ir,
1221 float amplitude,
1222 float gain = 2.f);
1223
1224void recast_cliff(Array &array,
1225 float talus,
1226 int ir,
1227 float amplitude,
1228 const Array *p_mask,
1229 float gain = 2.f);
1230
1263void recast_cliff_directional(Array &array,
1264 float talus,
1265 int ir,
1266 float amplitude,
1267 float angle,
1268 float gain = 2.f);
1269
1270void recast_cliff_directional(Array &array,
1271 float talus,
1272 int ir,
1273 float amplitude,
1274 float angle,
1275 const Array *p_mask,
1276 float gain = 2.f);
1277
1278void recast_cracks(Array &array,
1279 float cut_min = 0.05f,
1280 float cut_max = 0.5f,
1281 float k_smoothing = 0.01f,
1282 float vmin = 0.f,
1283 float vmax = -1.f);
1284
1321void recast_escarpment(Array &array,
1322 int ir = 16,
1323 float ratio = 0.1f,
1324 float scale = 1.f,
1325 bool reverse = false,
1326 bool transpose_effect = false,
1327 float global_scaling = 0.f);
1328
1367void recast_escarpment(Array &array,
1368 const Array *p_mask,
1369 int ir = 16,
1370 float ratio = 0.1f,
1371 float scale = 1.f,
1372 bool reverse = false,
1373 bool transpose_effect = false,
1374 float global_scaling = 0.f);
1375
1407void recast_peak(Array &array, int ir, float gamma = 2.f, float k = 0.1f);
1408
1409void recast_peak(Array &array,
1410 int ir,
1411 const Array *p_mask,
1412 float gamma = 2.f,
1413 float k = 0.1f);
1414
1459void recast_rocky_slopes(Array &array,
1460 float talus,
1461 int ir,
1462 float amplitude,
1463 uint seed,
1464 float kw,
1465 float gamma = 0.5f,
1466 const Array *p_noise = nullptr,
1467 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
1468
1470 Array &array,
1471 float talus,
1472 int ir,
1473 float amplitude,
1474 uint seed,
1475 float kw,
1476 const Array *p_mask,
1477 float gamma = 0.5f,
1478 const Array *p_noise = nullptr,
1479 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
1480
1508void recast_sag(Array &array, float vref, float k);
1509
1510void recast_sag(Array &array,
1511 float vref,
1512 float k,
1513 const Array *p_mask);
1514
1540void recurve(Array &array,
1541 const std::vector<float> &t,
1542 const std::vector<float> &v);
1543
1544void recurve(Array &array,
1545 const std::vector<float> &t,
1546 const std::vector<float> &v,
1547 const Array *p_mask);
1548
1576void recurve_bexp(Array &array, float tau = 0.5f);
1577
1579 const Array *p_mask,
1580 float tau = 0.5f);
1581
1609void recurve_exp(Array &array, float tau = 0.5f);
1610
1611void recurve_exp(Array &array,
1612 const Array *p_mask,
1613 float tau = 0.5f);
1614
1640void recurve_kura(Array &array, float a, float b);
1641
1642void recurve_kura(Array &array,
1643 float a,
1644 float b,
1645 const Array *p_mask);
1646
1668void recurve_s(Array &array);
1669
1670void recurve_s(Array &array, const Array *p_mask);
1671
1696void recurve_smoothstep_rational(Array &array, float n);
1697
1699 float n,
1700 const Array *p_mask);
1701
1730void reverse_above_theshold(Array &array,
1731 const Array &threshold,
1732 float scaling = 1.f,
1733 float transition_extent = 0.f);
1734
1735void reverse_above_theshold(Array &array,
1736 float threshold,
1737 float scaling = 1.f,
1738 float transition_extent = 0.f);
1739
1740void reverse_above_theshold(Array &array,
1741 const Array &threshold,
1742 const Array *p_mask,
1743 float scaling = 1.f,
1744 float transition_extent = 0.f);
1745
1746void reverse_above_theshold(Array &array,
1747 float threshold,
1748 const Array *p_mask,
1749 float scaling = 1.f,
1750 float transition_extent = 0.f);
1751
1772void saturate(Array &array,
1773 float vmin,
1774 float vmax,
1775 float from_min,
1776 float from_max,
1777 float k = 0.f);
1778
1779void saturate(Array &array, float vmin, float vmax, float k = 0.f);
1780
1805void sharpen(Array &array, float ratio = 1.f);
1806
1807void sharpen(Array &array,
1808 const Array *p_mask,
1809 float ratio = 1.f);
1810
1836void sharpen_cone(Array &array, int ir, float intensity = 0.5f);
1837
1838void sharpen_cone(Array &array,
1839 const Array *p_mask,
1840 int ir,
1841 float scale = 0.5f);
1842
1871void shrink(Array &array, int ir, int iterations = 1);
1872void shrink(Array &array,
1873 int ir,
1874 const Array *p_mask,
1875 int iterations = 1);
1876void shrink(Array &array,
1877 const Array &kernel,
1878 int iterations = 1);
1879void shrink(Array &array,
1880 const Array &kernel,
1881 const Array *p_mask,
1882 int iterations = 1);
1883
1913void shrink_directional(Array &array,
1914 int ir,
1915 float angle,
1916 float aspect_ratio,
1917 float anisotropy = 1.f,
1918 const Array *p_mask = nullptr);
1919
1940void smooth_cone(Array &array, int ir);
1941void smooth_cone(Array &array, int ir, const Array *p_mask);
1942
1968void smooth_cpulse(Array &array, int ir);
1969void smooth_cpulse(Array &array, int ir, const Array *p_mask);
1970
1991 float talus,
1992 float talus_width,
1993 int ir);
1994
2008void smooth_flat(Array &array, int ir);
2009
2032void smooth_gaussian(Array &array, int ir);
2033void smooth_gaussian(Array &array, int ir, const Array *p_mask);
2066void smooth_fill(Array &array,
2067 int ir,
2068 float k = 0.1f,
2069 Array *p_deposition_map = nullptr);
2070
2071void smooth_fill(Array &array,
2072 int ir,
2073 const Array *p_mask,
2074 float k = 0.1f,
2075 Array *p_deposition_map = nullptr);
2076
2100void smooth_fill_holes(Array &array, int ir);
2101void smooth_fill_holes(Array &array,
2102 int ir,
2103 const Array *p_mask);
2104
2128void smooth_fill_smear_peaks(Array &array, int ir);
2129void smooth_fill_smear_peaks(Array &array,
2130 int ir,
2131 const Array *p_mask);
2132
2149void smoothstep_local(Array &array, int ir);
2150
2171void smoothstep_local(Array &array, int ir, const Array *p_mask);
2172
2198void steepen(Array &array, float scale, int ir = 8);
2199void steepen(Array &array,
2200 float scale,
2201 const Array *p_mask,
2202 int ir = 8);
2203
2232void steepen_convective(Array &array,
2233 float angle,
2234 int iterations = 1,
2235 int ir = 0,
2236 float dt = 0.1f);
2237
2238void steepen_convective(Array &array,
2239 float angle,
2240 const Array *p_mask,
2241 int iterations = 1,
2242 int ir = 0,
2243 float dt = 0.1f);
2244
2278void terrace(Array &array,
2279 uint seed,
2280 int nlevels,
2281 float gain = 0.9f,
2282 float noise_ratio = 0.f,
2283 const Array *p_noise = nullptr,
2284 float vmin = 0.f,
2285 float vmax = -1.f);
2286
2327void terrace(Array &array,
2328 uint seed,
2329 int nlevels,
2330 const Array *p_mask,
2331 float gain = 0.9f,
2332 float noise_ratio = 0.f,
2333 const Array *p_noise = nullptr,
2334 float vmin = 0.f,
2335 float vmax = -1.f);
2336
2361Array tessellate(Array &array,
2362 uint seed,
2363 float node_density = 0.001f,
2364 const Array *p_weight = nullptr);
2365
2402void wrinkle(Array &array,
2403 float wrinkle_amplitude,
2404 const Array *p_mask,
2405 float wrinkle_angle = 0.f,
2406 float displacement_amplitude = 1.f,
2407 int ir = 0,
2408 float kw = 2.f,
2409 uint seed = 1,
2410 int octaves = 8,
2411 float weight = 0.7f,
2412 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
2413
2414void wrinkle(Array &array,
2415 float wrinkle_amplitude,
2416 float wrinkle_angle = 0.f,
2417 float displacement_amplitude = 1.f,
2418 int ir = 0,
2419 float kw = 2.f,
2420 uint seed = 1,
2421 int octaves = 8,
2422 float weight = 0.7f,
2423 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
2424
2425} // namespace hmap
2426
2427namespace hmap::gpu
2428{
2429
2431void expand(Array &array, int ir, int iterations = 1);
2432void expand(Array &array,
2433 int ir,
2434 const Array *p_mask,
2435 int iterations = 1);
2436void expand(Array &array,
2437 const Array &kernel,
2438 int iterations = 1);
2439void expand(Array &array,
2440 const Array &kernel,
2441 const Array *p_mask,
2442 int iterations = 1);
2443
2445void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
2446void gamma_correction_local(Array &array,
2447 float gamma,
2448 int ir,
2449 const Array *p_mask,
2450 float k = 0.1f);
2451
2453void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
2454void laplace(Array &array,
2455 const Array *p_mask,
2456 float sigma = 0.2f,
2457 int iterations = 3);
2458
2460Array maximum_local(const Array &array, int ir);
2461
2463Array maximum_local_disk(const Array &array, int ir);
2464
2466Array mean_shift(const Array &array,
2467 int ir,
2468 float talus,
2469 int iterations = 1,
2470 bool talus_weighted = true);
2471
2472Array mean_shift(const Array &array,
2473 int ir,
2474 float talus,
2475 const Array *p_mask,
2476 int iterations = 1,
2477 bool talus_weighted = true);
2478
2480void median_3x3(Array &array);
2481void median_3x3(Array &array, const Array *p_mask);
2482
2484Array median_pseudo(const Array &array, int ir);
2485
2487Array minimum_local(const Array &array, int ir);
2488
2490Array minimum_local_disk(const Array &array, int ir);
2491
2493void normal_displacement(Array &array,
2494 float amount = 0.1f,
2495 int ir = 0,
2496 bool reverse = false);
2497void normal_displacement(Array &array,
2498 const Array *p_mask,
2499 float amount = 0.1f,
2500 int ir = 0,
2501 bool reverse = false);
2502
2504void plateau(Array &array, const Array *p_mask, int ir, float factor);
2505void plateau(Array &array, int ir, float factor);
2506
2508void shrink(Array &array, int ir, int iterations = 1);
2509void shrink(Array &array,
2510 int ir,
2511 const Array *p_mask,
2512 int iterations = 1);
2513void shrink(Array &array,
2514 const Array &kernel,
2515 int iterations = 1);
2516void shrink(Array &array,
2517 const Array &kernel,
2518 const Array *p_mask,
2519 int iterations = 1);
2520
2522void smooth_cpulse(Array &array, int ir);
2523
2525void smooth_cpulse(Array &array, int ir, const Array *p_mask);
2526
2528void smooth_cpulse_edge_removing(Array &array,
2529 float talus,
2530 float talus_width,
2531 int ir);
2532
2534void smooth_fill(Array &array,
2535 int ir,
2536 float k = 0.1f,
2537 Array *p_deposition_map = nullptr);
2538void smooth_fill(Array &array,
2539 int ir,
2540 const Array *p_mask,
2541 float k = 0.1f,
2542 Array *p_deposition_map = nullptr);
2543
2545void smooth_fill_holes(Array &array, int ir);
2546void smooth_fill_holes(Array &array,
2547 int ir,
2548 const Array *p_mask);
2549
2551void smooth_fill_smear_peaks(Array &array, int ir);
2552void smooth_fill_smear_peaks(Array &array,
2553 int ir,
2554 const Array *p_mask);
2555
2556} // 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
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:621
void smooth_cpulse_edge_removing(Array &array, float talus, float talus_width, int ir)
See hmap::smooth_cpulse_edge_removing.
Definition filters_gpu.cpp:558
void smooth_fill_holes(Array &array, int ir)
See hmap::smooth_fill_holes.
Definition filters_gpu.cpp:593
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:392
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:486
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:569
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:28
void expand_talus(Array &z, const Array &mask, float talus, uint seed, float noise_ratio=0.2f)
Definition filters.cpp:166
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:536
Array median_pseudo(const Array &array, int ir)
Computes a fast pseudo-median approximation of a local neighborhood in an array.
Definition filters.cpp:756
void equalize(Array &array)
Apply histogram equalization to the array values.
Definition filters.cpp:42
void smooth_fill_holes(Array &array, int ir)
Apply smoothing to fill holes (elliptic concave surfaces).
Definition filters.cpp:1187
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
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:316
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 steepen(Array &array, float scale, int ir=8)
Steepen (or flatten) the array map.
Definition filters.cpp:1271
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:613
void smooth_gaussian(Array &array, int ir)
Apply Gaussian filtering to the array.
Definition filters.cpp:1112
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:827
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:1344
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:998
void sharpen_cone(Array &array, int ir, float intensity=0.5f)
Apply a sharpening filter based on a smooth cone filter.
Definition filters.cpp:936
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:488
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:910
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, Vec2< float > center={0.5f, 0.5f}, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Definition bulkify.cpp:11
void smooth_flat(Array &array, int ir)
Applies a smoothing average filter to the given 2D array in both dimensions.
Definition filters.cpp:1099
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:572
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:1294
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:632
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:623
void median_3x3(Array &array, const Array *p_mask)
Apply a 3x3 median filter to the input array.
Definition filters.cpp:744
void fill_talus_fast(Array &z, Vec2< int > shape_coarse, float talus, uint seed, float noise_ratio=0.2f)
Fill terrain values with a given downslope talus, optimized using a coarse mesh for faster computatio...
Definition filters.cpp:283
void smooth_cpulse(Array &array, int ir)
Apply filtering to the array using convolution with a cubic pulse kernel.
Definition filters.cpp:1050
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:1243
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:1088
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:763
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:346
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:839
void gamma_correction(Array &array, float gamma, const Array *p_mask)
Apply gamma correction to the input array.
Definition filters.cpp:368
void smooth_cone(Array &array, int ir)
Apply a convolution filter with a cone kernel to smooth the array.
Definition filters.cpp:1012
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 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, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Apply wrinkle effect to the array, creating wrinkled or bumpy features.
Definition filters.cpp:1465
void shrink(Array &array, int ir, int iterations=1)
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
Definition filters.cpp:955
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:380
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:429
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:91
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 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:1152
void fill_talus(Array &z, float talus, uint seed, float noise_ratio=0.2f)
Modifies a terrain array by filling it with talus slopes.
Definition filters.cpp:230
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 recast_rocky_slopes(Array &array, float talus, int ir, float amplitude, uint seed, float kw, float gamma=0.5f, const Array *p_noise=nullptr, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Transform heightmap by adding "rock-like" features at higher slopes.
Definition recast.cpp:333
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:1215
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:152
Core procedural primitives for heightmap generation, including noise functions (Perlin,...
Vec4 class for basic manipulation of 4D vectors.
Definition algebra.hpp:564