HighMap library (C++)
Loading...
Searching...
No Matches
gradient.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#include "highmap/tensor.hpp"
20
21namespace hmap
22{
23
50Array divergence_from_gradients(const Array &dx, const Array &dy);
51
61std::vector<float> gradient1d(const std::vector<float> &v);
62
81Array gradient_angle(const Array &array, bool downward = false);
82
117Array gradient_angle_circular_smoothing(const Array &array,
118 int ir,
119 bool downward = false);
120
141Array gradient_norm(const Array &array,
142 Array *p_dx = nullptr,
143 Array *p_dy = nullptr);
144
165Array gradient_norm_prewitt(const Array &array,
166 Array *p_dx = nullptr,
167 Array *p_dy = nullptr);
168
183Array gradient_norm_scharr(const Array &array,
184 Array *p_dx = nullptr,
185 Array *p_dy = nullptr);
186
201Array gradient_norm_sobel(const Array &array,
202 Array *p_dx = nullptr,
203 Array *p_dy = nullptr);
204
217Array gradient_talus(const Array &array);
218
228void gradient_talus(const Array &array, Array &talus);
229
239Array gradient_x(const Array &array);
240
251void gradient_x(const Array &array, Array &dx);
252
262Array gradient_y(const Array &array);
263
274void gradient_y(const Array &array, Array &dy);
275
285Array laplacian(const Array &array);
286
300Tensor normal_map(const Array &array);
301
329Array normal_map_to_heightmap(const Tensor &nmap);
330
356Array normal_map_to_heightmap_poisson(const Tensor &nmap,
357 int iterations = 500,
358 float omega = 1.5f);
359
395Array phase_field(const Array &array,
396 float kw,
397 int width,
398 uint seed,
399 float noise_amp = 0.f,
400 int prefilter_ir = -1,
401 float density_factor = 1.f,
402 bool rotate90 = false,
403 Array *p_gnoise_x = nullptr,
404 Array *p_gnoise_y = nullptr);
405
425void solve_poisson_gauss_seidel(const Array &rhs,
426 Array &h,
427 int iterations = 500,
428 float omega = 1.0f);
429
446Array unwrap_phase(const Array &alpha);
447
448} // namespace hmap
449
450namespace hmap::gpu
451{
452
454Array gradient_norm(const Array &array);
455
456} // 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
Definition blending.hpp:186
Array gradient_norm(const Array &array)
See hmap::gradient_norm.
Definition gradient_gpu.cpp:9
Definition algebra.hpp:28
void solve_poisson_gauss_seidel(const Array &rhs, Array &h, int iterations=500, float omega=1.0f)
Solve the Poisson equation ∇²h = rhs using Gauss–Seidel iteration.
Definition solve_poisson_gauss_seidel.cpp:9
Array gradient_x(const Array &array)
Compute the gradient in the x-direction of a 2D array.
Definition gradient.cpp:174
Array normal_map_to_heightmap(const Tensor &nmap)
Converts a normal map to a heightmap using direct summation of gradients.
Definition normal_map.cpp:32
Array divergence_from_gradients(const Array &dx, const Array &dy)
Compute the divergence of a 2D gradient field.
Definition gradient.cpp:62
Array unwrap_phase(const Array &alpha)
Unwraps a 2D phase array to correct discontinuities in phase data.
Definition unwrap_phase.cpp:14
Array gradient_norm_scharr(const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr)
Compute the gradient norm of a 2D array using the Scharr filter.
Definition gradient.cpp:162
Array normal_map_to_heightmap_poisson(const Tensor &nmap, int iterations=500, float omega=1.5f)
Reconstruct a height/displacement map from a normal map by solving a Poisson equation with Gauss–Seid...
Definition normal_map.cpp:65
Array gradient_angle_circular_smoothing(const Array &array, int ir, bool downward=false)
Computes a smoothed gradient angle (aspect) field with circular unwrapping.
Definition gradient.cpp:90
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:123
Array gradient_talus(const Array &array)
Compute the gradient talus slope of a 2D array.
Definition gradient.cpp:216
Array phase_field(const Array &array, float kw, int width, uint seed, float noise_amp=0.f, int prefilter_ir=-1, float density_factor=1.f, bool rotate90=false, Array *p_gnoise_x=nullptr, Array *p_gnoise_y=nullptr)
Computes a phase field using spatially varying Gabor noise based on the input heightmap.
Definition phase_field.cpp:16
Array laplacian(const Array &array)
Compute the Laplacian of a 2D array.
Definition gradient.cpp:244
Array gradient_y(const Array &array)
Compute the gradient in the y-direction of a 2D array.
Definition gradient.cpp:195
Array gradient_norm_prewitt(const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr)
Compute the gradient norm of a 2D array using the Prewitt filter.
Definition gradient.cpp:136
std::vector< float > gradient1d(const std::vector< float > &v)
Compute the gradient of a 1D vector.
Definition vector.cpp:17
Array gradient_norm_sobel(const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr)
Compute the gradient norm of a 2D array using the Sobel filter.
Definition gradient.cpp:149
Array gradient_angle(const Array &array, bool downward=false)
Compute the polar angle of the gradient of a 2D array.
Definition gradient.cpp:69
Tensor normal_map(const Array &array)
Generates a normal map from a given 2D array.
Definition normal_map.cpp:12
Header file for the Tensor class.