|
HighMap library (C++)
|
HeightMap class, to manipulate a set of RGBA heightmap for heightmap texturing. More...
#include <heightmap.hpp>

Public Member Functions | |
| HeightmapRGBA (Heightmap r, Heightmap g, Heightmap b, Heightmap a) | |
| Constructor. | |
| HeightmapRGBA (Vec2< int > shape, Vec2< int > tiling, float overlap, Array array_r, Array array_g, Array array_b, Array array_a) | |
| HeightmapRGBA (Vec2< int > shape, Vec2< int > tiling, float overlap) | |
| HeightmapRGBA () | |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | set_alpha (Heightmap new_alpha) |
| Set the alpha channel. | |
| void | set_alpha (float new_alpha) |
| void | set_sto (Vec2< int > new_shape, Vec2< int > new_tiling, float new_overlap) |
| Set the shape / tiling / overlap in one pass. | |
| void | to_png (const std::string &fname, int depth=CV_8U) |
| Export the RGB heightmap to a 8bit png file. | |
| void | colorize (Heightmap &color_level, float vmin, float vmax, int cmap, Heightmap *p_alpha=nullptr, bool reverse=false, Heightmap *p_noise=nullptr) |
| Fill RGB heightmap components based on a colormap and an input reference heightmap. | |
| void | colorize (Heightmap &color_level, float vmin, float vmax, std::vector< std::vector< float > > colormap_colors, Heightmap *p_alpha=nullptr, bool reverse=false, Heightmap *p_noise=nullptr) |
| Fill RGBA heightmap components based on a colormap and input reference heightmaps for the color level and the transparency. | |
| void | colorize (Heightmap &color_level, float vmin, float vmax, std::vector< float > positions, std::vector< std::vector< float > > colormap_colors, Heightmap *p_alpha=nullptr, bool reverse=false, Heightmap *p_noise=nullptr) |
| Heightmap | luminance () |
| Computes the luminance of an RGBA height map. | |
| void | normalize () |
| Normalize RGBA heightmaps amplitude. | |
| std::vector< uint8_t > | to_img_8bit (Vec2< int > shape_img={0, 0}, bool flip_y=true) const |
| Convert the RGB heightmap to a 8bit RGB image. | |
Public Attributes | |
| std::vector< Heightmap > | rgba |
| RGBA component heightmap storage. | |
| Vec2< int > | shape = {0, 0} |
| Shape. | |
Friends | |
| HeightmapRGBA | mix_heightmap_rgba (HeightmapRGBA &rgba1, HeightmapRGBA &rgba2, bool use_sqrt_avg) |
| Mix two RGBA heightmap using alpha compositing ("over"). | |
| HeightmapRGBA | mix_heightmap_rgba (std::vector< HeightmapRGBA * > rgba_plist, bool use_sqrt_avg) |
| Mix two RGBA heightmap using alpha compositing ("over"). | |
HeightMap class, to manipulate a set of RGBA heightmap for heightmap texturing.
Example
Result
| hmap::HeightmapRGBA::HeightmapRGBA | ( | Vec2< int > | shape, |
| Vec2< int > | tiling, | ||
| float | overlap, | ||
| Array | array_r, | ||
| Array | array_g, | ||
| Array | array_b, | ||
| Array | array_a | ||
| ) |
| hmap::HeightmapRGBA::HeightmapRGBA | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::HeightmapRGBA::set_alpha | ( | Heightmap | new_alpha | ) |
Set the alpha channel.
| new_alpha | Alpha value(s). |
| void hmap::HeightmapRGBA::set_alpha | ( | float | new_alpha | ) |
| void hmap::HeightmapRGBA::set_sto | ( | Vec2< int > | new_shape, |
| Vec2< int > | new_tiling, | ||
| float | new_overlap | ||
| ) |
Set the shape / tiling / overlap in one pass.
| new_shape | New shape. |
| new_tiling | New tiling. |
| new_overlap | New overlap. |
| void hmap::HeightmapRGBA::to_png | ( | const std::string & | fname, |
| int | depth = CV_8U |
||
| ) |
Export the RGB heightmap to a 8bit png file.
| fname | File name. |
| void hmap::HeightmapRGBA::colorize | ( | Heightmap & | color_level, |
| float | vmin, | ||
| float | vmax, | ||
| int | cmap, | ||
| Heightmap * | p_alpha = nullptr, |
||
| bool | reverse = false, |
||
| Heightmap * | p_noise = nullptr |
||
| ) |
Fill RGB heightmap components based on a colormap and an input reference heightmap.
| color_level | Input heightmap for color level. |
| vmin | Lower bound for scaling to array [0, 1]. |
| vmax | Upper bound for scaling to array [0, 1] |
| cmap | Colormap (see cmap). |
| p_alpha | Reference to input heightmap for alpha channel, expected in [0, 1]. |
| reverse | Reverse colormap. |
| void hmap::HeightmapRGBA::colorize | ( | Heightmap & | color_level, |
| float | vmin, | ||
| float | vmax, | ||
| std::vector< std::vector< float > > | colormap_colors, | ||
| Heightmap * | p_alpha = nullptr, |
||
| bool | reverse = false, |
||
| Heightmap * | p_noise = nullptr |
||
| ) |
Fill RGBA heightmap components based on a colormap and input reference heightmaps for the color level and the transparency.
| color_level | Input heightmap for color level. |
| vmin | Lower bound for scaling to array [0, 1]. |
| vmax | Upper bound for scaling to array [0, 1] |
| colormap_colors | Colormap RGB colors as a vector of RGB colors. |
| p_alpha | Reference to input heightmap for alpha channel, expected in [0, 1]. |
| reverse | Reverse colormap. |
| void hmap::HeightmapRGBA::colorize | ( | Heightmap & | color_level, |
| float | vmin, | ||
| float | vmax, | ||
| std::vector< float > | positions, | ||
| std::vector< std::vector< float > > | colormap_colors, | ||
| Heightmap * | p_alpha = nullptr, |
||
| bool | reverse = false, |
||
| Heightmap * | p_noise = nullptr |
||
| ) |
| Heightmap hmap::HeightmapRGBA::luminance | ( | ) |
Computes the luminance of an RGBA height map.
This method creates a grayscale HeightMap based on the luminance values calculated from the red, green, and blue channels of the RGBA height map. The luminance is computed using the standard formula: \(
L =
0.299 \times R + 0.587 \times G + 0.114 \times B \).
HeightMap representing the grayscale luminance of the current RGBA height map.| void hmap::HeightmapRGBA::normalize | ( | ) |
Normalize RGBA heightmaps amplitude.
| std::vector< uint8_t > hmap::HeightmapRGBA::to_img_8bit | ( | Vec2< int > | shape_img = {0, 0}, |
| bool | flip_y = true |
||
| ) | const |
Convert the RGB heightmap to a 8bit RGB image.
| shape_img | Resulting image shape. |
|
friend |
Mix two RGBA heightmap using alpha compositing ("over").
| rgba1 | 1st RGBA heightmap. |
| rgba2 | 2st RGBA heightmap. |
| use_sqrt_avg | Whether to use or not square averaging. |
|
friend |
Mix two RGBA heightmap using alpha compositing ("over").
| rgba_plist | Heightmap reference list. |
| use_sqrt_avg | Whether to use or not square averaging. |
| std::vector<Heightmap> hmap::HeightmapRGBA::rgba |
RGBA component heightmap storage.
| Vec2<int> hmap::HeightmapRGBA::shape = {0, 0} |
Shape.