HighMap library (C++)
Loading...
Searching...
No Matches
gradient.hpp File Reference

Provides functions for calculating gradients and related operations on arrays. This header file defines functions to compute various gradient operations including gradient norms, gradient angles, and Laplacians for 2D arrays. It supports different gradient filters such as Prewitt, Sobel, and Scharr. More...

Go to the source code of this file.

Namespaces

namespace  hmap
 
namespace  hmap::gpu
 

Functions

Array hmap::divergence_from_gradients (const Array &dx, const Array &dy)
 Compute the divergence of a 2D gradient field.
 
std::vector< float > hmap::gradient1d (const std::vector< float > &v)
 Compute the gradient of a 1D vector.
 
Array hmap::gradient_angle (const Array &array, bool downward=false)
 Compute the polar angle of the gradient of a 2D array.
 
Array hmap::gradient_angle_circular_smoothing (const Array &array, int ir, bool downward=false)
 Computes a smoothed gradient angle (aspect) field with circular unwrapping.
 
Array hmap::gradient_norm (const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr)
 Compute the gradient norm of a 2D array.
 
Array hmap::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.
 
Array hmap::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.
 
Array hmap::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.
 
Array hmap::gradient_talus (const Array &array)
 Compute the gradient talus slope of a 2D array.
 
void hmap::gradient_talus (const Array &array, Array &talus)
 Compute the gradient talus slope and store it in the provided array.
 
Array hmap::gradient_x (const Array &array)
 Compute the gradient in the x-direction of a 2D array.
 
void hmap::gradient_x (const Array &array, Array &dx)
 Compute the gradient in the x-direction of a 2D array and store it.
 
Array hmap::gradient_y (const Array &array)
 Compute the gradient in the y-direction of a 2D array.
 
void hmap::gradient_y (const Array &array, Array &dy)
 Compute the gradient in the y-direction of a 2D array and store it.
 
Array hmap::laplacian (const Array &array)
 Compute the Laplacian of a 2D array.
 
Tensor hmap::normal_map (const Array &array)
 Generates a normal map from a given 2D array.
 
Array hmap::normal_map_to_heightmap (const Tensor &nmap)
 Converts a normal map to a heightmap using direct summation of gradients.
 
Array hmap::normal_map_to_heightmap_poisson (const Tensor &nmap, int iterations=500, float omega=1.5f)
 
void hmap::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.
 
Array hmap::unwrap_phase (const Array &alpha)
 Unwraps a 2D phase array to correct discontinuities in phase data.
 
Array hmap::talus_jump_mask (const Array &z, float threshold, float sigma)
 
void hmap::gpu::phase_averaging (Array &field_real, Array &field_imag, int ir)
 Apply phase averaging on real and imaginary fields using a GPU kernel.
 
Array hmap::gpu::phase_field (const Array &array, const glm::vec2 &kw, uint seed, float kp, bool rotate90=false, int n_kernel_samples=8, const glm::vec2 &jitter={0.5f, 0.5f}, int angle_filter_ir=8, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
 Compute a phase field from an input array using local orientation and noise.
 
Array hmap::gpu::phase_field (const Array &array, uint seed, float kp_global, bool rotate90=false, int n_kernel_samples=8, const glm::vec2 &jitter={0.5f, 0.5f}, int angle_filter_ir=8, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
 Compute a phase field using a global isotropic kp value.
 
Array hmap::gpu::phase_field_angle (const Array &angle, const glm::vec2 &kw, uint seed, float kp, int n_kernel_samples=8, const glm::vec2 &jitter={0.5f, 0.5f}, int angle_filter_ir=8, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
 
Array hmap::gpu::gradient_angle_circular_smoothing (const Array &array, int ir, bool downward=false)
 See hmap::gradient_angle_circular_smoothing.
 
Array hmap::gpu::gradient_norm (const Array &array)
 See hmap::gradient_norm.
 

Detailed Description

Provides functions for calculating gradients and related operations on arrays. This header file defines functions to compute various gradient operations including gradient norms, gradient angles, and Laplacians for 2D arrays. It supports different gradient filters such as Prewitt, Sobel, and Scharr.

Author
Otto Link (otto..nosp@m.link.nosp@m..bv@g.nosp@m.mail.nosp@m..com)