HighMap library (C++)
Loading...
Searching...
No Matches
selector.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
13#pragma once
14
15#include "highmap/array.hpp"
16#include "highmap/range.hpp"
17
18namespace hmap
19{
20
51Array perturb_mask_contour(const Array &mask,
52 const Array &noise,
53 float max_displacement,
54 int ir = 1);
55
72Array scan_mask(const Array &array,
73 float contrast = 0.5f,
74 float brightness = 0.5f);
75
91Array select_angle(const Array &array, float angle, float sigma, int ir = 0);
92
107Array select_blob_log(const Array &array, int ir);
108
125Array select_cavities(const Array &array, int ir, bool concave = true);
126
140Array select_elevation_slope(const Array &array, float gradient_scale);
141Array select_elevation_slope(const Array &array,
142 float gradient_scale,
143 float vmax);
144
163Array select_eq(const Array &array, float value);
164
173Array select_gradient_angle(const Array &array, float angle);
174
183Array select_gradient_binary(const Array &array, float talus_center);
184
194Array select_gradient_exp(const Array &array,
195 float talus_center,
196 float talus_sigma);
197
207Array select_gradient_inv(const Array &array,
208 float talus_center,
209 float talus_sigma);
210
229Array select_gt(const Array &array, float value);
230
250Array select_interval(const Array &array, float value1, float value2);
251
266Array select_inward_outward_slope(const Array &array,
267 glm::vec2 center = {0.5f, 0.5f},
268 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
269
288Array select_lt(const Array &array, float value);
289
306Array select_midrange(const Array &array, float gain, float vmin, float vmax);
307
324Array select_midrange(const Array &array, float gain);
325
356void select_multiband3(const Array &array,
357 Array &band_low,
358 Array &band_mid,
359 Array &band_high,
360 float ratio1,
361 float ratio2,
362 float overlap,
363 float vmin,
364 float vmax);
365
391void select_multiband3(const Array &array,
392 Array &band_low,
393 Array &band_mid,
394 Array &band_high,
395 float ratio1,
396 float ratio2,
397 float overlap);
398
415Array select_pulse(const Array &array, float value, float sigma);
416
433Array select_rivers(const Array &array, float talus_ref, float clipping_ratio);
434
452Array select_transitions(const Array &array1,
453 const Array &array2,
454 const Array &array_blend);
455
456Array select_valley(const Array &z, int ir, bool ridge_select = false);
457
458} // namespace hmap
459
460namespace hmap::gpu
461{
462
464Array select_cavities(const Array &array, int ir, bool concave = true);
465
492Array select_soil_flow(const Array &z,
493 int ir_gradient = 1,
494 float gradient_weight = 1.f,
495 float gradient_scaling_factor = 0.f,
496 float flow_weight = 0.05f,
497 float talus_ref = 0.f,
498 float clipping_ratio = 50.f,
499 float flow_gamma = 1.f,
500 float k_smooth = 0.01f);
501
530 const Array &z,
531 int ir_max = 64,
532 int ir_min = 0,
533 int steps = 4,
534 float smaller_scales_weight = 1.f,
535 ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
536 float curvature_clamping = 1.f);
537
572 const Array &z,
573 int ir_curvature = 0,
574 int ir_gradient = 4,
575 ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
576 float curvature_clamping = 10.f,
577 float curvature_weight = 1.f,
578 float gradient_weight = 1.f,
579 float gradient_scaling_factor = 0.f);
580
581// if the gradient norm is known before-hand
582Array select_soil_weathered(const Array &z,
583 const Array &gradient_norm, // in [0, 1]
584 int ir_curvature,
585 ClampMode curvature_clamp_mode,
586 float curvature_clamping,
587 float curvature_weight,
588 float gradient_weight,
589 float gradient_scaling_factor); // for curvature
590
592Array select_valley(const Array &z, int ir, bool ridge_select = false);
593
594} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition blending.hpp:186
Array select_valley(const Array &z, int ir, bool ridge_select=false)
See hmap::select_valley.
Definition selector_gpu.cpp:25
Array gradient_norm(const Array &array)
See hmap::gradient_norm.
Definition gradient_gpu.cpp:50
Array select_soil_rocks(const Array &z, int ir_max=64, int ir_min=0, int steps=4, float smaller_scales_weight=1.f, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=1.f)
Computes a multi-scale soil/rock selector using curvature analysis.
Definition select_soil_rocks.cpp:15
Array select_cavities(const Array &array, int ir, bool concave=true)
See hmap::select_cavities.
Definition selector_gpu.cpp:13
Array select_soil_weathered(const Array &z, int ir_curvature=0, int ir_gradient=4, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=10.f, float curvature_weight=1.f, float gradient_weight=1.f, float gradient_scaling_factor=0.f)
Computes a soil weathering selection map based on curvature and gradient analysis.
Definition select_soil_weathered.cpp:14
Array select_soil_flow(const Array &z, int ir_gradient=1, float gradient_weight=1.f, float gradient_scaling_factor=0.f, float flow_weight=0.05f, float talus_ref=0.f, float clipping_ratio=50.f, float flow_gamma=1.f, float k_smooth=0.01f)
Computes a soil–flow selection map based on terrain gradient, river mask, and smoothing parameters.
Definition select_soil_flow.cpp:13
Definition algebra.hpp:23
Array select_lt(const Array &array, float value)
Return an array with elements equal to 1 where input elements are smaller than value.
Definition selector.cpp:198
Array perturb_mask_contour(const Array &mask, const Array &noise, float max_displacement, int ir=1)
Perturb the contour of a binary mask using a displacement field, while trying to preserve a single co...
Definition perturb_mask_contour.cpp:13
Array select_elevation_slope(const Array &array, float gradient_scale)
Definition selector.cpp:87
Array select_angle(const Array &array, float angle, float sigma, int ir=0)
Return angle selection for a given angle and a tolerance half-width on this value.
Definition selector.cpp:43
Array select_pulse(const Array &array, float value, float sigma)
Return an array filled with non-zero values where the input is in the interval [value - sigma,...
Definition selector.cpp:298
Array select_rivers(const Array &array, float talus_ref, float clipping_ratio)
Return an array filled with a criterion based on the occurence of a river bed.
Definition selector.cpp:313
Array select_gradient_exp(const Array &array, float talus_center, float talus_sigma)
Return an array weighted (exponantial decay) by the gradient norm of the input array.
Definition selector.cpp:130
Array select_gt(const Array &array, float value)
Return an array with elements equal to 1 where input elements are larger than value.
Definition selector.cpp:101
Array select_gradient_inv(const Array &array, float talus_center, float talus_sigma)
Return an array weighted (square inverse) by the gradient norm of the input array.
Definition selector.cpp:140
Array scan_mask(const Array &array, float contrast=0.5f, float brightness=0.5f)
Mask adjustement using a 'scanning' method.
Definition selector.cpp:21
void select_multiband3(const Array &array, Array &band_low, Array &band_mid, Array &band_high, float ratio1, float ratio2, float overlap, float vmin, float vmax)
Splits the input array into three bands (low, mid, and high) based on given ratios and overlap.
Definition selector.cpp:232
Array select_midrange(const Array &array, float gain, float vmin, float vmax)
Selects the midrange values of the input array within a specified range.
Definition selector.cpp:207
Array select_interval(const Array &array, float value1, float value2)
Return an array with elements equal to 1 where input elements are within the bounds provided.
Definition selector.cpp:150
Array select_inward_outward_slope(const Array &array, glm::vec2 center={0.5f, 0.5f}, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Return an array with positive values if the slope is pointing to the center (slope is inward),...
Definition selector.cpp:164
Array select_gradient_angle(const Array &array, float angle)
Return an array weighted by the gap between the gradient angle and a given angle.
Definition selector.cpp:110
Array noise(NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Return an array filled with coherence noise.
Definition noise.cpp:16
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:46
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:173
Array select_cavities(const Array &array, int ir, bool concave=true)
Return holes or bumps detection based on the mean curvature of the heightmap.
Definition selector.cpp:65
Array select_transitions(const Array &array1, const Array &array2, const Array &array_blend)
Return an array filled with 1 at the blending transition between two arrays, and 0 elsewhere.
Definition selector.cpp:326
Array select_valley(const Array &z, int ir, bool ridge_select=false)
Definition selector.cpp:387
Array select_gradient_binary(const Array &array, float talus_center)
Return an array filled with 1 where the gradient is larger than a given value and 0 elsewhere.
Definition selector.cpp:121
Array select_eq(const Array &array, float value)
Return an array with elements equal to 1 where input elements are equal to value.
Definition selector.cpp:92
ClampMode
Definition range.hpp:25
@ POSITIVE_ONLY
Definition range.hpp:26
Array select_blob_log(const Array &array, int ir)
Return blob detection using the Laplacian of Gaussian (LoG) approach.
Definition selector.cpp:56
Header file for range control functions and utilities.