HighMap library (C++)
Loading...
Searching...
No Matches
hmap::Heightmap Class Reference

HeightMap class, to manipulate heightmap (with contextual informations). More...

#include <heightmap.hpp>

Collaboration diagram for hmap::Heightmap:

Public Member Functions

 Heightmap (Vec2< int > shape, Vec2< int > tiling, float overlap)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 Heightmap (Vec2< int > shape, Vec2< int > tiling, float overlap, float fill_value)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 Heightmap (Vec2< int > shape, Vec2< int > tiling)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 Heightmap (Vec2< int > shape)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 Heightmap ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
size_t get_ntiles () const
 Get the number of tiles.
 
int get_tile_index (int i, int j) const
 Get the tile linear index.
 
float get_value_bilinear (float x, float y) const
 
float get_value_nearest (float x, float y) const
 
void set_overlap (float new_overlap)
 Set the tile overlapping.
 
void set_shape (Vec2< int > new_shape)
 Set the heightmap shape.
 
void set_sto (Vec2< int > new_shape, Vec2< int > new_tiling, float new_overlap)
 Set the shape / tiling / overlap in one pass.
 
void set_tiling (Vec2< int > new_tiling)
 Set the tiling setup.
 
void from_array_interp (Array &array)
 Fill tile values by interpolating (bilinear) values from another array.
 
void from_array_interp_bicubic (Array &array)
 Fill tile values by interpolating (bicubic) values from another array.
 
void from_array_interp_bilinear (Array &array)
 Fill tile values by interpolating (bilinear) values from another array.
 
void from_array_interp_nearest (Array &array)
 Fill tile values by interpolating (nearest neighbor) values from another array.
 
void infos ()
 Print some informations about the object.
 
void inverse ()
 Inverse the heightmap values (max - values).
 
float max ()
 Return the value of the greatest element in the heightmap data.
 
float mean ()
 Return the mean of the heightmap data.
 
float min ()
 Return the value of the smallest element in the heightmap data.
 
void remap (float vmin=0.f, float vmax=1.f)
 Remap heightmap elements from a starting range to a target range.
 
void remap (float vmin, float vmax, float from_min, float from_max)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void smooth_overlap_buffers ()
 Smooth the transitions between each tiles (when overlap > 0).
 
float sum ()
 Return the sum of the heightmap data.
 
Array to_array (Vec2< int > shape_export)
 Return the heightmap as an array.
 
Array to_array ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< uint16_t > to_grayscale_image_16bit ()
 Converts the heightmap to a 16-bit grayscale representation.
 
std::vector< uint16_t > to_grayscale_image_16bit_multithread ()
 
std::vector< uint8_t > to_grayscale_image_8bit ()
 
std::vector< float > unique_values ()
 Returns the unique elements of the heightmap.
 
void update_tile_parameters ()
 Update tile parameters.
 

Public Attributes

Vec2< int > shape
 Heightmap global shape.
 
Vec2< int > tiling = {1, 1}
 Tiling setup (number of tiles in each direction).
 
float overlap = 0.f
 Tile overlapping, in [0, 1[.
 
std::vector< Tiletiles = {}
 Tile storage.
 

Detailed Description

HeightMap class, to manipulate heightmap (with contextual informations).

Constructor & Destructor Documentation

◆ Heightmap() [1/5]

hmap::Heightmap::Heightmap ( Vec2< int >  shape,
Vec2< int >  tiling,
float  overlap 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Heightmap() [2/5]

hmap::Heightmap::Heightmap ( Vec2< int >  shape,
Vec2< int >  tiling,
float  overlap,
float  fill_value 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Heightmap() [3/5]

hmap::Heightmap::Heightmap ( Vec2< int >  shape,
Vec2< int >  tiling 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Heightmap() [4/5]

hmap::Heightmap::Heightmap ( Vec2< int >  shape)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Heightmap() [5/5]

hmap::Heightmap::Heightmap ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Member Function Documentation

◆ get_ntiles()

size_t hmap::Heightmap::get_ntiles ( ) const

Get the number of tiles.

Returns
size_t Number of tiles.

◆ get_tile_index()

int hmap::Heightmap::get_tile_index ( int  i,
int  j 
) const

Get the tile linear index.

Parameters
iTile i index.
jTile j index
Returns
int Linear index.

◆ get_value_bilinear()

float hmap::Heightmap::get_value_bilinear ( float  x,
float  y 
) const

◆ get_value_nearest()

float hmap::Heightmap::get_value_nearest ( float  x,
float  y 
) const

◆ set_overlap()

void hmap::Heightmap::set_overlap ( float  new_overlap)

Set the tile overlapping.

Parameters
new_overlapNew overlap.

◆ set_shape()

void hmap::Heightmap::set_shape ( Vec2< int >  new_shape)

Set the heightmap shape.

Parameters
new_shapeNew shape.

◆ set_sto()

void hmap::Heightmap::set_sto ( Vec2< int >  new_shape,
Vec2< int >  new_tiling,
float  new_overlap 
)

Set the shape / tiling / overlap in one pass.

Parameters
new_shapeNew shape.
new_tilingNew tiling.
new_overlapNew overlap.

◆ set_tiling()

void hmap::Heightmap::set_tiling ( Vec2< int >  new_tiling)

Set the tiling setup.

Parameters
new_tilingNew tiling.

◆ from_array_interp()

void hmap::Heightmap::from_array_interp ( Array array)

Fill tile values by interpolating (bilinear) values from another array.

Parameters
arrayInput array.

Example

#include "highmap.hpp"
int main(void)
{
hmap::Vec2<int> shape = {256, 256};
float overlap = 0.25;
hmap::Vec2<float> kw = {4.f, 4.f};
int seed = 1;
hmap::Vec2<int>(64, 64),
kw,
seed);
z.to_png("ex_heightmap_from_array0.png", hmap::Cmap::INFERNO);
h.to_array().to_png("ex_heightmap_from_array1.png", hmap::Cmap::INFERNO);
}
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
void to_png(const std::string &fname, int cmap, bool hillshading=false, int depth=CV_8U) const
Export the array as a PNG image file with a specified colormap and hillshading.
Definition io.cpp:122
HeightMap class, to manipulate heightmap (with contextual informations).
Definition heightmap.hpp:150
Array to_array(Vec2< int > shape_export)
Return the heightmap as an array.
Definition heightmap_base.cpp:386
Vec2< int > tiling
Tiling setup (number of tiles in each direction).
Definition heightmap.hpp:160
float overlap
Tile overlapping, in [0, 1[.
Definition heightmap.hpp:165
Vec2< int > shape
Heightmap global shape.
Definition heightmap.hpp:155
void from_array_interp_bicubic(Array &array)
Fill tile values by interpolating (bicubic) values from another array.
Definition heightmap_base.cpp:109
Array noise(NoiseType noise_type, Vec2< int > shape, Vec2< float > kw, uint seed, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, Vec4< float > bbox={0.f, 1.f, 0.f, 1.f})
Return an array filled with coherence noise.
Definition noise.cpp:16
@ PERLIN
Perlin.
Definition functions.hpp:64
@ INFERNO
Definition colormaps.hpp:85
Vec2 class for basic manipulation of 2D vectors.
Definition algebra.hpp:40

Result

◆ from_array_interp_bicubic()

void hmap::Heightmap::from_array_interp_bicubic ( Array array)

Fill tile values by interpolating (bicubic) values from another array.

Parameters
arrayInput array.

◆ from_array_interp_bilinear()

void hmap::Heightmap::from_array_interp_bilinear ( Array array)

Fill tile values by interpolating (bilinear) values from another array.

Parameters
arrayInput array.

◆ from_array_interp_nearest()

void hmap::Heightmap::from_array_interp_nearest ( Array array)

Fill tile values by interpolating (nearest neighbor) values from another array.

Parameters
arrayInput array.

◆ infos()

void hmap::Heightmap::infos ( )

Print some informations about the object.

◆ inverse()

void hmap::Heightmap::inverse ( )

Inverse the heightmap values (max - values).

◆ max()

float hmap::Heightmap::max ( )

Return the value of the greatest element in the heightmap data.

Returns
float

◆ mean()

float hmap::Heightmap::mean ( )

Return the mean of the heightmap data.

Returns
float

◆ min()

float hmap::Heightmap::min ( )

Return the value of the smallest element in the heightmap data.

Returns
float

◆ remap() [1/2]

void hmap::Heightmap::remap ( float  vmin = 0.f,
float  vmax = 1.f 
)

Remap heightmap elements from a starting range to a target range.

By default the starting range is taken to be [min(), max()] of the input array.

Parameters
arrayInput array.
vminThe lower bound of the range to remap to.
vmaxThe lower bound of the range to remap to.
from_minThe lower bound of the range to remap from.
from_maxThe upper bound of the range to remap from.

◆ remap() [2/2]

void hmap::Heightmap::remap ( float  vmin,
float  vmax,
float  from_min,
float  from_max 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ smooth_overlap_buffers()

void hmap::Heightmap::smooth_overlap_buffers ( )

Smooth the transitions between each tiles (when overlap > 0).

◆ sum()

float hmap::Heightmap::sum ( )

Return the sum of the heightmap data.

Returns
float

◆ to_array() [1/2]

Array hmap::Heightmap::to_array ( Vec2< int >  shape_export)

Return the heightmap as an array.

Parameters
shape_exportArray shape.
Returns
Array Resulting array.

◆ to_array() [2/2]

Array hmap::Heightmap::to_array ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_grayscale_image_16bit()

std::vector< uint16_t > hmap::Heightmap::to_grayscale_image_16bit ( )

Converts the heightmap to a 16-bit grayscale representation.

Returns
A std::vector<uint16_t> containing the 16-bit grayscale image data.

◆ to_grayscale_image_16bit_multithread()

std::vector< uint16_t > hmap::Heightmap::to_grayscale_image_16bit_multithread ( )

◆ to_grayscale_image_8bit()

std::vector< uint8_t > hmap::Heightmap::to_grayscale_image_8bit ( )

◆ unique_values()

std::vector< float > hmap::Heightmap::unique_values ( )

Returns the unique elements of the heightmap.

Returns
std::vector<float> Unique values.

◆ update_tile_parameters()

void hmap::Heightmap::update_tile_parameters ( )

Update tile parameters.

Member Data Documentation

◆ shape

Vec2<int> hmap::Heightmap::shape

Heightmap global shape.

◆ tiling

Vec2<int> hmap::Heightmap::tiling = {1, 1}

Tiling setup (number of tiles in each direction).

◆ overlap

float hmap::Heightmap::overlap = 0.f

Tile overlapping, in [0, 1[.

◆ tiles

std::vector<Tile> hmap::Heightmap::tiles = {}

Tile storage.


The documentation for this class was generated from the following files: