HighMap library (C++)
Loading...
Searching...
No Matches
hmap::HeightmapRGBA Struct Reference

HeightMap class, to manipulate a set of RGBA heightmap for heightmap texturing. More...

#include <heightmap.hpp>

Collaboration diagram for hmap::HeightmapRGBA:

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< Heightmaprgba
 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").
 

Detailed Description

HeightMap class, to manipulate a set of RGBA heightmap for heightmap texturing.

Example

Result

Constructor & Destructor Documentation

◆ HeightmapRGBA() [1/4]

hmap::HeightmapRGBA::HeightmapRGBA ( Heightmap  r,
Heightmap  g,
Heightmap  b,
Heightmap  a 
)

Constructor.

Parameters
rHeightmap for R (red) component.
gHeightmap for G (green) component.
bHeightmap for B (blue) component.
aHeightmap for A (alpha) component.

◆ HeightmapRGBA() [2/4]

hmap::HeightmapRGBA::HeightmapRGBA ( Vec2< int >  shape,
Vec2< int >  tiling,
float  overlap,
Array  array_r,
Array  array_g,
Array  array_b,
Array  array_a 
)

◆ HeightmapRGBA() [3/4]

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

◆ HeightmapRGBA() [4/4]

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.

Member Function Documentation

◆ set_alpha() [1/2]

void hmap::HeightmapRGBA::set_alpha ( Heightmap  new_alpha)

Set the alpha channel.

Parameters
new_alphaAlpha value(s).

◆ set_alpha() [2/2]

void hmap::HeightmapRGBA::set_alpha ( float  new_alpha)

◆ set_sto()

void hmap::HeightmapRGBA::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.

◆ to_png()

void hmap::HeightmapRGBA::to_png ( const std::string &  fname,
int  depth = CV_8U 
)

Export the RGB heightmap to a 8bit png file.

Parameters
fnameFile name.

◆ colorize() [1/3]

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.

Parameters
color_levelInput heightmap for color level.
vminLower bound for scaling to array [0, 1].
vmaxUpper bound for scaling to array [0, 1]
cmapColormap (see cmap).
p_alphaReference to input heightmap for alpha channel, expected in [0, 1].
reverseReverse colormap.

◆ colorize() [2/3]

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.

Parameters
color_levelInput heightmap for color level.
vminLower bound for scaling to array [0, 1].
vmaxUpper bound for scaling to array [0, 1]
colormap_colorsColormap RGB colors as a vector of RGB colors.
p_alphaReference to input heightmap for alpha channel, expected in [0, 1].
reverseReverse colormap.

◆ colorize() [3/3]

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 
)

◆ luminance()

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 \).

Returns
A HeightMap representing the grayscale luminance of the current RGBA height map.
See also
https://stackoverflow.com/questions/596216 for details on the luminance calculation.

◆ normalize()

void hmap::HeightmapRGBA::normalize ( )

Normalize RGBA heightmaps amplitude.

◆ to_img_8bit()

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.

Parameters
shape_imgResulting image shape.
Returns
Image data.

Friends And Related Symbol Documentation

◆ mix_heightmap_rgba [1/2]

HeightmapRGBA mix_heightmap_rgba ( HeightmapRGBA rgba1,
HeightmapRGBA rgba2,
bool  use_sqrt_avg = true 
)
friend

Mix two RGBA heightmap using alpha compositing ("over").

Parameters
rgba11st RGBA heightmap.
rgba22st RGBA heightmap.
use_sqrt_avgWhether to use or not square averaging.
Returns
RGBA heightmap.

◆ mix_heightmap_rgba [2/2]

HeightmapRGBA mix_heightmap_rgba ( std::vector< HeightmapRGBA * >  rgba_plist,
bool  use_sqrt_avg = true 
)
friend

Mix two RGBA heightmap using alpha compositing ("over").

Parameters
rgba_plistHeightmap reference list.
use_sqrt_avgWhether to use or not square averaging.
Returns
RGBA heightmap.

Member Data Documentation

◆ rgba

std::vector<Heightmap> hmap::HeightmapRGBA::rgba

RGBA component heightmap storage.

◆ shape

Vec2<int> hmap::HeightmapRGBA::shape = {0, 0}

Shape.


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