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"
17#include "highmap/range.hpp"
20
21namespace hmap
22{
23
55 const Array &noise,
56 float max_displacement,
57 int ir = 1);
58
75Array scan_mask(const Array &array,
76 float contrast = 0.5f,
77 float brightness = 0.5f);
78
93Array select_angle(const Array &array, float angle, float sigma);
94
112Array select_blob_log(const Array &array,
113 int ir,
114 bool normalize = false,
116
136Array select_cavities(const Array &array,
137 int ir,
138 bool concave = true,
139 bool normalize = false,
141
160Array select_eq(const Array &array, float value);
161
170Array select_gradient_angle(const Array &array, float angle);
171
180Array select_gradient_binary(const Array &array, float talus_center);
181
191Array select_gradient_exp(const Array &array,
192 float talus_center,
193 float talus_sigma);
194
204Array select_gradient_inv(const Array &array,
205 float talus_center,
206 float talus_sigma);
207
226Array select_gt(const Array &array, float value);
227
247Array select_interval(const Array &array, float value1, float value2);
248
264 glm::vec2 center = {0.5f, 0.5f},
265 const BBox2D &bbox = BBox2D::unit());
266
285Array select_lt(const Array &array, float value);
286
303Array select_midrange(const Array &array, float gain, float vmin, float vmax);
304
321Array select_midrange(const Array &array, float gain);
322
353void select_multiband3(const Array &array,
354 Array &band_low,
355 Array &band_mid,
356 Array &band_high,
357 float ratio1,
358 float ratio2,
359 float overlap,
360 float vmin,
361 float vmax);
362
388void select_multiband3(const Array &array,
389 Array &band_low,
390 Array &band_mid,
391 Array &band_high,
392 float ratio1,
393 float ratio2,
394 float overlap);
395
412Array select_pulse(const Array &array, float value, float sigma);
413
428Array select_range(const Array &array, float vmin, float vmax, float width);
429
446Array select_rivers(const Array &array, float talus_ref, float clipping_ratio);
447
465Array select_transitions(const Array &array1,
466 const Array &array2,
467 const Array &array_blend);
468
469Array select_valley(const Array &z,
470 int ir,
471 bool ridge_select = false,
472 bool normalize = false,
474
489 const Array &mask,
490 float feather_width,
491 const UvTile &region = UvTile::dummy(),
493
494} // namespace hmap
495
496namespace hmap::gpu
497{
498
500Array select_cavities(const Array &array,
501 int ir,
502 bool concave = true,
503 bool normalize = false,
504 ICommunicator &comm = SingleArrayComm::instance());
505
536Array select_soil_flow(const Array &z,
537 int ir_gradient = 1,
538 float gradient_weight = 1.f,
539 float gradient_scaling_factor = 0.f,
540 float flow_weight = 0.05f,
541 float talus_ref = 0.f,
542 float clipping_ratio = 50.f,
543 float flow_gamma = 1.f,
544 float k_smooth = 0.01f,
545 bool normalize = false,
546 ICommunicator &comm = SingleArrayComm::instance());
547
578
580 const Array &z,
581 int ir_max = 64,
582 int ir_min = 0,
583 int steps = 4,
584 float smaller_scales_weight = 1.f,
585 ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
586 float curvature_clamping = 1.f,
587 bool normalize = false,
588 ICommunicator &comm = SingleArrayComm::instance());
589
628 const Array &z,
629 int ir_curvature = 0,
630 int ir_gradient = 4,
631 ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
632 float curvature_clamping = 10.f,
633 float curvature_weight = 1.f,
634 float gradient_weight = 1.f,
635 float gradient_scaling_factor = 0.f,
636 bool normalize = false,
637 ICommunicator &comm = SingleArrayComm::instance());
638
639// if the gradient norm is known before-hand
640Array select_soil_weathered(const Array &z,
641 const Array &gradient_norm, // in [0, 1]
642 int ir_curvature,
643 ClampMode curvature_clamp_mode,
644 float curvature_clamping,
645 float curvature_weight,
646 float gradient_weight,
647 float gradient_scaling_factor, // for curvature
648 bool normalize = false,
649 ICommunicator &comm = SingleArrayComm::instance());
650
666Array select_slope(const Array &z,
667 int ir = 0,
668 bool normalize = false,
670 const UvTile &region = UvTile::dummy(),
671 ICommunicator &comm = SingleArrayComm::instance());
672
674Array select_valley(const Array &z,
675 int ir,
676 bool ridge_select = false,
677 bool normalize = false,
678 ICommunicator &comm = SingleArrayComm::instance());
679
680} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Abstract communicator interface providing MPI-style collective directives for single-source SPMD Arra...
Definition communicator_interface.hpp:60
static SingleArrayComm & instance()
Definition communicator.cpp:78
Definition array_blending.hpp:225
Array select_cavities(const Array &array, int ir, bool concave=true, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
See hmap::select_cavities.
Definition selector_gpu.cpp:16
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, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a soil–flow selection map based on terrain gradient, river mask, and smoothing parameters.
Definition select_soil_flow.cpp:14
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, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a multi-scale soil/rock selector using curvature analysis.
Definition select_soil_rocks.cpp:16
Array select_slope(const Array &z, int ir=0, bool normalize=false, MinMaxKernel kernel_type=MinMaxKernel::OCTAGON, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Selects terrain slope.
Definition selector_gpu.cpp:40
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, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a soil weathering selection map based on curvature and gradient analysis.
Definition select_soil_weathered.cpp:15
Array select_valley(const Array &z, int ir, bool ridge_select=false, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
See hmap::select_valley.
Definition selector_gpu.cpp:63
Definition opencv.hpp:20
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:245
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:14
Array select_blob_log(const Array &array, int ir, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Return blob detection using the Laplacian of Gaussian (LoG) approach.
Definition selector.cpp:79
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:354
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:404
void normalize(Array &array, NormalizationMethod method)
In-place normalization of an array.
Definition normalize.cpp:16
MinMaxKernel
Kernel footprint geometry for local minimum / maximum operations.
Definition local_metrics.hpp:22
@ OCTAGON
Octagonal neighborhood (separable 4-pass approximation).
Definition local_metrics.hpp:24
Array smooth_mask_preserve_frontier(const Array &mask, float feather_width, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Smooths a binary mask with an inward falloff while preserving its 0-boundary.
Definition selector.cpp:503
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:169
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:134
Array gradient_norm(const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr)
Compute the gradient norm of a 2D array.
Definition gradient.cpp:131
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:181
Array select_angle(const Array &array, float angle, float sigma)
Return angle selection for a given angle and a tolerance half-width on this value.
Definition selector.cpp:47
Array scan_mask(const Array &array, float contrast=0.5f, float brightness=0.5f)
Mask adjustement using a 'scanning' method.
Definition selector.cpp:23
Array select_cavities(const Array &array, int ir, bool concave=true, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Return holes or bumps detection based on the mean curvature of the heightmap.
Definition selector.cpp:99
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:284
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:256
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:193
UvTile UvTile
Definition communicator_interface.hpp:49
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:145
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
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 UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f)
Return an array filled with coherence noise.
Definition noise.cpp:17
void gain(Array &array, float factor, const Array *p_mask)
Apply a gain correction to the array elements.
Definition filters.cpp:251
Array select_valley(const Array &z, int ir, bool ridge_select=false, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Definition selector.cpp:484
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:419
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:158
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:123
ClampMode
Definition range.hpp:26
@ POSITIVE_ONLY
Definition range.hpp:27
Array select_inward_outward_slope(const Array &array, glm::vec2 center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
Return an array with positive values if the slope is pointing to the center (slope is inward),...
Definition selector.cpp:209
Array select_range(const Array &array, float vmin, float vmax, float width)
Return a selection mask for a value range [vmin, vmax] with smooth transitions of specified width at ...
Definition selector.cpp:371
Header file for range control functions and utilities.
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25
static constexpr BBox2D unit()
Definition bbox2d.hpp:39
Describes an Array tile's position within the normalized [0, 1]^2 UV domain and global index grid.
Definition uv_tile.hpp:46
static const UvTile & dummy()
Definition uv_tile.cpp:37
Normalized UV-domain tile descriptor for single-source SPMD Array algorithms and VirtualArray dispatc...