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
20namespace hmap
21{
22
31enum neighborhood : int
32{
35 // orthogonal
37 CROSS
38 // neighbors.
39};
40
69Array diffusion_retargeting(const Array &array_before,
70 const Array &array_after,
71 int ir);
72
114void directional_blur(Array &array,
115 int ir,
116 float angle,
117 float intensity,
118 float stretch = 1.f,
119 float spread = 1.f);
120
144void directional_blur(Array &array,
145 int ir,
146 const Array &angle,
147 float intensity,
148 float stretch = 1.f,
149 float spread = 1.f);
150
159void equalize(Array &array);
160
174void equalize(Array &array, const Array *p_mask);
175
197void expand(Array &array, int ir, const Array *p_mask, int iterations = 1);
198
211void expand(Array &array, int ir, int iterations = 1);
212
224void expand(Array &array, const Array &kernel, int iterations = 1);
225
240void expand(Array &array,
241 const Array &kernel,
242 const Array *p_mask,
243 int iterations = 1);
244
273void expand_directional(Array &array,
274 int ir,
275 float angle,
276 float aspect_ratio,
277 float anisotropy = 1.f,
278 const Array *p_mask = nullptr);
279
280void expand_talus(Array &z,
281 const Array &mask,
282 float talus,
283 uint seed,
284 float noise_ratio = 0.2f);
285
312Array faceted(const Array &array,
313 int neighborhood = 0,
314 const Array *p_noise_x = nullptr,
315 const Array *p_noise_y = nullptr);
316
348void fill_talus(Array &z, float talus, uint seed, float noise_ratio = 0.2f);
349
387void fill_talus_fast(Array &z,
388 Vec2<int> shape_coarse,
389 float talus,
390 uint seed,
391 float noise_ratio = 0.2f);
392
421void fold(Array &array,
422 float vmin,
423 float vmax,
424 int iterations = 3,
425 float k = 0.05f);
426
444void fold(Array &array, int iterations = 3, float k = 0.05f);
445
469void gain(Array &array, float factor, const Array *p_mask);
470
483void gain(Array &array, float factor);
484
511void gamma_correction(Array &array, float gamma, const Array *p_mask);
512
526void gamma_correction(Array &array, float gamma);
527
556void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
557
581void gamma_correction_local(Array &array,
582 float gamma,
583 int ir,
584 const Array *p_mask,
585 float k = 0.1f);
586
608void kuwahara(Array &array, int ir, float mix_ratio = 1.f);
609
638void kuwahara(Array &array, int ir, const Array *p_mask, float mix_ratio = 1.f);
639
660void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
661
683void laplace(Array &array,
684 const Array *p_mask,
685 float sigma = 0.2f,
686 int iterations = 3);
687
702void laplace1d(std::vector<float> &v, float sigma = 0.5f, int iterations = 1);
703
730void laplace_edge_preserving(Array &array,
731 float talus,
732 float sigma = 0.2f,
733 int iterations = 3);
734
760void laplace_edge_preserving(Array &array,
761 float talus,
762 const Array *p_mask,
763 float sigma = 0.2f,
764 int iterations = 3);
765
789void low_pass_high_order(Array &array, int order = 9, float sigma = 1.f);
790
804void make_binary(Array &array, float threshold = 0.f);
805
828Array maximum_local(const Array &array, int ir);
829
852Array maximum_local_disk(const Array &array, int ir);
853
874void match_histogram(Array &array, const Array &array_reference);
875
904Array mean_shift(const Array &array,
905 int ir,
906 float talus,
907 int iterations = 1,
908 bool talus_weighted = true);
909
910Array mean_shift(const Array &array,
911 int ir,
912 float talus,
913 const Array *p_mask,
914 int iterations = 1,
915 bool talus_weighted = true);
916
936void median_3x3(Array &array, const Array *p_mask);
937
949void median_3x3(Array &array);
950
984Array median_pseudo(const Array &array, int ir);
985
1008Array minimum_local(const Array &array, int ir);
1009
1032Array minimum_local_disk(const Array &array, int ir);
1033
1058void normal_displacement(Array &array,
1059 float amount = 0.1f,
1060 int ir = 0,
1061 bool reverse = false);
1062
1063void normal_displacement(Array &array,
1064 const Array *p_mask,
1065 float amount = 0.1f,
1066 int ir = 0,
1067 bool reverse = false);
1068
1093void plateau(Array &array, const Array *p_mask, int ir, float factor);
1094
1095void plateau(Array &array, int ir, float factor);
1118void recast_billow(Array &array, float vref, float k);
1119
1147void recast_canyon(Array &array, const Array &vcut, float gamma = 4.f);
1148
1149void recast_canyon(Array &array,
1150 const Array &vcut,
1151 const Array *p_mask,
1152 float gamma = 4.f);
1153
1154void recast_canyon(Array &array,
1155 float vcut,
1156 const Array *p_mask,
1157 float gamma = 4.f,
1158 const Array *p_noise = nullptr);
1159
1160void recast_canyon(Array &array,
1161 float vcut,
1162 float gamma = 4.f,
1163 const Array *p_noise = nullptr);
1164
1194void recast_cliff(Array &array,
1195 float talus,
1196 int ir,
1197 float amplitude,
1198 float gain = 2.f);
1199
1200void recast_cliff(Array &array,
1201 float talus,
1202 int ir,
1203 float amplitude,
1204 const Array *p_mask,
1205 float gain = 2.f);
1206
1239void recast_cliff_directional(Array &array,
1240 float talus,
1241 int ir,
1242 float amplitude,
1243 float angle,
1244 float gain = 2.f);
1245
1246void recast_cliff_directional(Array &array,
1247 float talus,
1248 int ir,
1249 float amplitude,
1250 float angle,
1251 const Array *p_mask,
1252 float gain = 2.f);
1253
1254void recast_cracks(Array &array,
1255 float cut_min = 0.05f,
1256 float cut_max = 0.5f,
1257 float k_smoothing = 0.01f,
1258 float vmin = 0.f,
1259 float vmax = -1.f);
1260
1297void recast_escarpment(Array &array,
1298 int ir = 16,
1299 float ratio = 0.1f,
1300 float scale = 1.f,
1301 bool reverse = false,
1302 bool transpose_effect = false,
1303 float global_scaling = 0.f);
1304
1343void recast_escarpment(Array &array,
1344 const Array *p_mask,
1345 int ir = 16,
1346 float ratio = 0.1f,
1347 float scale = 1.f,
1348 bool reverse = false,
1349 bool transpose_effect = false,
1350 float global_scaling = 0.f);
1351
1383void recast_peak(Array &array, int ir, float gamma = 2.f, float k = 0.1f);
1384
1385void recast_peak(Array &array,
1386 int ir,
1387 const Array *p_mask,
1388 float gamma = 2.f,
1389 float k = 0.1f);
1390
1435void recast_rocky_slopes(Array &array,
1436 float talus,
1437 int ir,
1438 float amplitude,
1439 uint seed,
1440 float kw,
1441 float gamma = 0.5f,
1442 const Array *p_noise = nullptr,
1443 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
1444
1446 Array &array,
1447 float talus,
1448 int ir,
1449 float amplitude,
1450 uint seed,
1451 float kw,
1452 const Array *p_mask,
1453 float gamma = 0.5f,
1454 const Array *p_noise = nullptr,
1455 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
1456
1484void recast_sag(Array &array, float vref, float k);
1485
1486void recast_sag(Array &array,
1487 float vref,
1488 float k,
1489 const Array *p_mask);
1490
1516void recurve(Array &array,
1517 const std::vector<float> &t,
1518 const std::vector<float> &v);
1519
1520void recurve(Array &array,
1521 const std::vector<float> &t,
1522 const std::vector<float> &v,
1523 const Array *p_mask);
1524
1552void recurve_bexp(Array &array, float tau = 0.5f);
1553
1555 const Array *p_mask,
1556 float tau = 0.5f);
1557
1585void recurve_exp(Array &array, float tau = 0.5f);
1586
1587void recurve_exp(Array &array,
1588 const Array *p_mask,
1589 float tau = 0.5f);
1590
1616void recurve_kura(Array &array, float a, float b);
1617
1618void recurve_kura(Array &array,
1619 float a,
1620 float b,
1621 const Array *p_mask);
1622
1644void recurve_s(Array &array);
1645
1646void recurve_s(Array &array, const Array *p_mask);
1647
1672void recurve_smoothstep_rational(Array &array, float n);
1673
1675 float n,
1676 const Array *p_mask);
1677
1706void reverse_above_theshold(Array &array,
1707 const Array &threshold,
1708 float scaling = 1.f,
1709 float transition_extent = 0.f);
1710
1711void reverse_above_theshold(Array &array,
1712 float threshold,
1713 float scaling = 1.f,
1714 float transition_extent = 0.f);
1715
1716void reverse_above_theshold(Array &array,
1717 const Array &threshold,
1718 const Array *p_mask,
1719 float scaling = 1.f,
1720 float transition_extent = 0.f);
1721
1722void reverse_above_theshold(Array &array,
1723 float threshold,
1724 const Array *p_mask,
1725 float scaling = 1.f,
1726 float transition_extent = 0.f);
1727
1748void saturate(Array &array,
1749 float vmin,
1750 float vmax,
1751 float from_min,
1752 float from_max,
1753 float k = 0.f);
1754
1755void saturate(Array &array, float vmin, float vmax, float k = 0.f);
1756
1781void sharpen(Array &array, float ratio = 1.f);
1782
1783void sharpen(Array &array,
1784 const Array *p_mask,
1785 float ratio = 1.f);
1786
1812void sharpen_cone(Array &array, int ir, float intensity = 0.5f);
1813
1814void sharpen_cone(Array &array,
1815 const Array *p_mask,
1816 int ir,
1817 float scale = 0.5f);
1818
1847void shrink(Array &array, int ir, int iterations = 1);
1848void shrink(Array &array,
1849 int ir,
1850 const Array *p_mask,
1851 int iterations = 1);
1852void shrink(Array &array,
1853 const Array &kernel,
1854 int iterations = 1);
1855void shrink(Array &array,
1856 const Array &kernel,
1857 const Array *p_mask,
1858 int iterations = 1);
1859
1889void shrink_directional(Array &array,
1890 int ir,
1891 float angle,
1892 float aspect_ratio,
1893 float anisotropy = 1.f,
1894 const Array *p_mask = nullptr);
1895
1916void smooth_cone(Array &array, int ir);
1917void smooth_cone(Array &array, int ir, const Array *p_mask);
1918
1944void smooth_cpulse(Array &array, int ir);
1945void smooth_cpulse(Array &array, int ir, const Array *p_mask);
1946
1960void smooth_flat(Array &array, int ir);
1961
1984void smooth_gaussian(Array &array, int ir);
1985void smooth_gaussian(Array &array, int ir, const Array *p_mask);
2018void smooth_fill(Array &array,
2019 int ir,
2020 float k = 0.1f,
2021 Array *p_deposition_map = nullptr);
2022
2023void smooth_fill(Array &array,
2024 int ir,
2025 const Array *p_mask,
2026 float k = 0.1f,
2027 Array *p_deposition_map = nullptr);
2028
2052void smooth_fill_holes(Array &array, int ir);
2053void smooth_fill_holes(Array &array,
2054 int ir,
2055 const Array *p_mask);
2056
2080void smooth_fill_smear_peaks(Array &array, int ir);
2081void smooth_fill_smear_peaks(Array &array,
2082 int ir,
2083 const Array *p_mask);
2084
2101void smoothstep_local(Array &array, int ir);
2102
2123void smoothstep_local(Array &array, int ir, const Array *p_mask);
2124
2150void steepen(Array &array, float scale, int ir = 8);
2151void steepen(Array &array,
2152 float scale,
2153 const Array *p_mask,
2154 int ir = 8);
2155
2184void steepen_convective(Array &array,
2185 float angle,
2186 int iterations = 1,
2187 int ir = 0,
2188 float dt = 0.1f);
2189
2190void steepen_convective(Array &array,
2191 float angle,
2192 const Array *p_mask,
2193 int iterations = 1,
2194 int ir = 0,
2195 float dt = 0.1f);
2196
2230void terrace(Array &array,
2231 uint seed,
2232 int nlevels,
2233 float gain = 0.9f,
2234 float noise_ratio = 0.f,
2235 const Array *p_noise = nullptr,
2236 float vmin = 0.f,
2237 float vmax = -1.f);
2238
2279void terrace(Array &array,
2280 uint seed,
2281 int nlevels,
2282 const Array *p_mask,
2283 float gain = 0.9f,
2284 float noise_ratio = 0.f,
2285 const Array *p_noise = nullptr,
2286 float vmin = 0.f,
2287 float vmax = -1.f);
2288
2313Array tessellate(Array &array,
2314 uint seed,
2315 float node_density = 0.001f,
2316 const Array *p_weight = nullptr);
2317
2354void wrinkle(Array &array,
2355 float wrinkle_amplitude,
2356 const Array *p_mask,
2357 float wrinkle_angle = 0.f,
2358 float displacement_amplitude = 1.f,
2359 int ir = 0,
2360 float kw = 2.f,
2361 uint seed = 1,
2362 int octaves = 8,
2363 float weight = 0.7f,
2364 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
2365
2366void wrinkle(Array &array,
2367 float wrinkle_amplitude,
2368 float wrinkle_angle = 0.f,
2369 float displacement_amplitude = 1.f,
2370 int ir = 0,
2371 float kw = 2.f,
2372 uint seed = 1,
2373 int octaves = 8,
2374 float weight = 0.7f,
2375 Vec4<float> bbox = {0.f, 1.f, 0.f, 1.f});
2376
2377} // namespace hmap
2378
2379namespace hmap::gpu
2380{
2381
2383void expand(Array &array, int ir, int iterations = 1);
2384void expand(Array &array,
2385 int ir,
2386 const Array *p_mask,
2387 int iterations = 1);
2388void expand(Array &array,
2389 const Array &kernel,
2390 int iterations = 1);
2391void expand(Array &array,
2392 const Array &kernel,
2393 const Array *p_mask,
2394 int iterations = 1);
2395
2397void gamma_correction_local(Array &array, float gamma, int ir, float k = 0.1f);
2398void gamma_correction_local(Array &array,
2399 float gamma,
2400 int ir,
2401 const Array *p_mask,
2402 float k = 0.1f);
2403
2405void laplace(Array &array, float sigma = 0.2f, int iterations = 3);
2406void laplace(Array &array,
2407 const Array *p_mask,
2408 float sigma = 0.2f,
2409 int iterations = 3);
2410
2412Array maximum_local(const Array &array, int ir);
2413
2415Array maximum_local_disk(const Array &array, int ir);
2416
2418Array mean_shift(const Array &array,
2419 int ir,
2420 float talus,
2421 int iterations = 1,
2422 bool talus_weighted = true);
2423
2424Array mean_shift(const Array &array,
2425 int ir,
2426 float talus,
2427 const Array *p_mask,
2428 int iterations = 1,
2429 bool talus_weighted = true);
2430
2432void median_3x3(Array &array);
2433void median_3x3(Array &array, const Array *p_mask);
2434
2436Array median_pseudo(const Array &array, int ir);
2437
2439Array minimum_local(const Array &array, int ir);
2440
2442Array minimum_local_disk(const Array &array, int ir);
2443
2445void normal_displacement(Array &array,
2446 float amount = 0.1f,
2447 int ir = 0,
2448 bool reverse = false);
2449void normal_displacement(Array &array,
2450 const Array *p_mask,
2451 float amount = 0.1f,
2452 int ir = 0,
2453 bool reverse = false);
2454
2456void plateau(Array &array, const Array *p_mask, int ir, float factor);
2457void plateau(Array &array, int ir, float factor);
2458
2460void shrink(Array &array, int ir, int iterations = 1);
2461void shrink(Array &array,
2462 int ir,
2463 const Array *p_mask,
2464 int iterations = 1);
2465void shrink(Array &array,
2466 const Array &kernel,
2467 int iterations = 1);
2468void shrink(Array &array,
2469 const Array &kernel,
2470 const Array *p_mask,
2471 int iterations = 1);
2472
2474void smooth_cpulse(Array &array, int ir);
2475
2477void smooth_cpulse(Array &array, int ir, const Array *p_mask);
2478
2480void smooth_fill(Array &array,
2481 int ir,
2482 float k = 0.1f,
2483 Array *p_deposition_map = nullptr);
2484void smooth_fill(Array &array,
2485 int ir,
2486 const Array *p_mask,
2487 float k = 0.1f,
2488 Array *p_deposition_map = nullptr);
2489
2491void smooth_fill_holes(Array &array, int ir);
2492void smooth_fill_holes(Array &array,
2493 int ir,
2494 const Array *p_mask);
2495
2497void smooth_fill_smear_peaks(Array &array, int ir);
2498void smooth_fill_smear_peaks(Array &array,
2499 int ir,
2500 const Array *p_mask);
2501
2502} // 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:151
Array minimum_local_disk(const Array &array, int ir)
See hmap::minimum_local_disk.
Definition filters_gpu.cpp:300
void laplace(Array &array, float sigma=0.2f, int iterations=3)
See hmap::laplace.
Definition filters_gpu.cpp:143
Array maximum_local(const Array &array, int ir)
See hmap::maximum_local.
Definition filters_gpu.cpp:182
Array median_pseudo(const Array &array, int ir)
See hmap::median_pseudo.
Definition filters_gpu.cpp:288
void expand(Array &array, int ir, int iterations=1)
See hmap::expand.
Definition filters_gpu.cpp:15
void smooth_fill_smear_peaks(Array &array, int ir)
See hmap::smooth_fill_smear_peaks.
Definition filters_gpu.cpp:609
void smooth_fill_holes(Array &array, int ir)
See hmap::smooth_fill_holes.
Definition filters_gpu.cpp:581
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:213
void shrink(Array &array, int ir, int iterations=1)
See hmap::shrink.
Definition filters_gpu.cpp:391
void gamma_correction_local(Array &array, float gamma, int ir, float k=0.1f)
See hmap::gamma_correction_local.
Definition filters_gpu.cpp:94
void smooth_cpulse(Array &array, int ir)
See hmap::smooth_cpulse.
Definition filters_gpu.cpp:485
void normal_displacement(Array &array, float amount=0.1f, int ir=0, bool reverse=false)
See hmap::normal_displacement.
Definition filters_gpu.cpp:308
void smooth_fill(Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
See hmap::smooth_fill.
Definition filters_gpu.cpp:557
Array maximum_local_disk(const Array &array, int ir)
See hmap::maximum_local_disk.
Definition filters_gpu.cpp:205
void plateau(Array &array, const Array *p_mask, int ir, float factor)
See hmap::plateau.
Definition filters_gpu.cpp:358
void median_3x3(Array &array)
See hmap::median_3x3.
Definition filters_gpu.cpp:263
Array minimum_local(const Array &array, int ir)
See hmap::minimum_local.
Definition filters_gpu.cpp:295
Definition algebra.hpp:28
void expand_talus(Array &z, const Array &mask, float talus, uint seed, float noise_ratio=0.2f)
Definition filters.cpp:167
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:510
Array median_pseudo(const Array &array, int ir)
Computes a fast pseudo-median approximation of a local neighborhood in an array.
Definition filters.cpp:730
void equalize(Array &array)
Apply histogram equalization to the array values.
Definition filters.cpp:43
void smooth_fill_holes(Array &array, int ir)
Apply smoothing to fill holes (elliptic concave surfaces).
Definition filters.cpp:1150
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:237
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:321
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:317
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:1234
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:587
void smooth_gaussian(Array &array, int ir)
Apply Gaussian filtering to the array.
Definition filters.cpp:1075
Array maximum_local(const Array &array, int ir)
Return the local maxima based on a maximum filter with a square kernel.
Definition range.cpp:200
void plateau(Array &array, const Array *p_mask, int ir, float factor)
Apply a plateau-shape filter to the input array.
Definition filters.cpp:801
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:1307
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:972
void sharpen_cone(Array &array, int ir, float intensity=0.5f)
Apply a sharpening filter based on a smooth cone filter.
Definition filters.cpp:910
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:884
void smooth_flat(Array &array, int ir)
Applies a smoothing average filter to the given 2D array in both dimensions.
Definition filters.cpp:1062
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:546
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:1257
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:606
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:597
void median_3x3(Array &array, const Array *p_mask)
Apply a 3x3 median filter to the input array.
Definition filters.cpp:718
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:284
void smooth_cpulse(Array &array, int ir)
Apply filtering to the array using convolution with a cubic pulse kernel.
Definition filters.cpp:1024
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:32
@ VON_NEUMANN
Von Neumann neighborhood: includes only the four.
Definition filters.hpp:34
@ CROSS
neighbors (N, S, E, W).
Definition filters.hpp:37
@ MOORE
Moore neighborhood: includes all eight surrounding cells.
Definition filters.hpp:33
void smoothstep_local(Array &array, int ir)
Applies a localized smoothstep operation to the provided array.
Definition filters.cpp:1206
void recurve_s(Array &array)
Apply a curve adjustment filter using a smooth "S-shape" curve.
Definition recurve.cpp:126
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:737
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:347
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:16
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:813
void gamma_correction(Array &array, float gamma, const Array *p_mask)
Apply gamma correction to the input array.
Definition filters.cpp:369
void smooth_cone(Array &array, int ir)
Apply a convolution filter with a cone kernel to smooth the array.
Definition filters.cpp:986
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:31
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:1428
void shrink(Array &array, int ir, int iterations=1)
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
Definition filters.cpp:929
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:381
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:430
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:316
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:92
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 laplace(Array &array, float sigma=0.2f, int iterations=3)
Apply a low-pass Laplace filter to the input array.
Definition filters.cpp:489
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:1115
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:231
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:1178
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:153
Vec4 class for basic manipulation of 4D vectors.
Definition algebra.hpp:564