|
HighMap library (C++)
|
A class to represent a multi-channel texture using planar hmap::Array storage. More...
#include <texture.hpp>

Public Member Functions | |
| Texture ()=default | |
| Construct an empty Texture object. | |
| Texture (glm::ivec2 shape, int num_channels) | |
| Construct a new Texture object with shape and channel count. | |
| Texture (glm::ivec2 shape, int num_channels, float fill_value) | |
| Construct a new Texture object with shape, channel count and fill value. | |
| Texture (const Array &array) | |
| Construct a single-channel Texture from an Array. | |
| Texture (const Array &r, const Array &g, const Array &b) | |
| Construct a 3-channel Texture from three Arrays. | |
| Texture (const Array &r, const Array &g, const Array &b, const Array &a) | |
| Construct a 4-channel Texture from four Arrays. | |
| Texture (const std::vector< Array > &channels) | |
| Construct a Texture from a list of Arrays. | |
| Texture (const std::string &fname, bool flip_j=false) | |
| Constructs a new Texture object from an image file. | |
| int | num_channels () const |
| Get the number of channels. | |
| Array & | operator[] (size_t idx) |
| Access channel Array by index. | |
| const Array & | operator[] (size_t idx) const |
| Array & | channel (size_t idx) |
| Access channel Array by index. | |
| const Array & | channel (size_t idx) const |
| float & | operator() (int i, int j, int c) |
| Access element at (i, j) in channel c. | |
| const float & | operator() (int i, int j, int c) const |
| Access element at (i, j) in channel c (const). | |
| glm::vec3 | get_pixel3 (int i, int j) const |
| Read 3-channel color at (i, j) as glm::vec3. | |
| glm::vec4 | get_pixel4 (int i, int j) const |
| Read 4-channel color at (i, j) as glm::vec4. | |
| void | set_pixel (int i, int j, const glm::vec3 &color) |
| Write 3-channel color at (i, j) from glm::vec3. | |
| void | set_pixel (int i, int j, const glm::vec4 &color) |
| Write 4-channel color at (i, j) from glm::vec4. | |
| float | max () const |
| Find the maximum value in all channels. | |
| float | min () const |
| Find the minimum value in all channels. | |
| void | remap (float vmin=0.f, float vmax=1.f) |
| Remap the texture values to a new range. | |
| Texture | resample_to_shape (glm::ivec2 new_shape_xy) const |
| Resamples the texture to a new 2D shape (x, y). | |
| cv::Mat | to_cv_mat () const |
| Convert the texture to an OpenCV matrix. | |
| std::vector< uint8_t > | to_img_8bit (bool flip_y=false) const |
| Convert the texture to an 8-bit image represented as a vector. | |
| void | to_png (const std::string &fname, int depth=CV_8U) const |
| Saves the Texture as an image file (e.g. PNG). | |
Public Attributes | |
| glm::ivec2 | shape = glm::ivec2(0, 0) |
| Shape of the texture in 2D space (x, y). | |
| std::vector< Array > | channels |
| Vector of planar Array channels. | |
A class to represent a multi-channel texture using planar hmap::Array storage.
The Texture class represents a multi-channel image/texture. Each channel is stored as a separate Array object, allowing direct use of Array functions and operators on individual channels without copying.
|
default |
Construct an empty Texture object.
| hmap::Texture::Texture | ( | glm::ivec2 | shape, |
| int | num_channels | ||
| ) |
Construct a new Texture object with shape and channel count.
| shape | 2D shape of the texture. |
| num_channels | Number of channels. |
| hmap::Texture::Texture | ( | glm::ivec2 | shape, |
| int | num_channels, | ||
| float | fill_value | ||
| ) |
Construct a new Texture object with shape, channel count and fill value.
| shape | 2D shape of the texture. |
| num_channels | Number of channels. |
| fill_value | The value to fill all channels with. |
|
explicit |
Construct a 3-channel Texture from three Arrays.
Construct a 4-channel Texture from four Arrays.
|
explicit |
Construct a Texture from a list of Arrays.
|
explicit |
Constructs a new Texture object from an image file.
| fname | The name of the file to load the texture from. |
| flip_j | If true, flip the image vertically on load. |
|
inline |
Get the number of channels.
|
inline |
|
inline |
|
inline |
Access element at (i, j) in channel c.
|
inline |
Access element at (i, j) in channel c (const).
| glm::vec3 hmap::Texture::get_pixel3 | ( | int | i, |
| int | j | ||
| ) | const |
Read 3-channel color at (i, j) as glm::vec3.
| glm::vec4 hmap::Texture::get_pixel4 | ( | int | i, |
| int | j | ||
| ) | const |
Read 4-channel color at (i, j) as glm::vec4.
| void hmap::Texture::set_pixel | ( | int | i, |
| int | j, | ||
| const glm::vec3 & | color | ||
| ) |
Write 3-channel color at (i, j) from glm::vec3.
| void hmap::Texture::set_pixel | ( | int | i, |
| int | j, | ||
| const glm::vec4 & | color | ||
| ) |
Write 4-channel color at (i, j) from glm::vec4.
| float hmap::Texture::max | ( | ) | const |
Find the maximum value in all channels.
| float hmap::Texture::min | ( | ) | const |
Find the minimum value in all channels.
Remap the texture values to a new range.
| Texture hmap::Texture::resample_to_shape | ( | glm::ivec2 | new_shape_xy | ) | const |
Resamples the texture to a new 2D shape (x, y).
| cv::Mat hmap::Texture::to_cv_mat | ( | ) | const |
Convert the texture to an OpenCV matrix.
| std::vector< uint8_t > hmap::Texture::to_img_8bit | ( | bool | flip_y = false | ) | const |
Convert the texture to an 8-bit image represented as a vector.
| void hmap::Texture::to_png | ( | const std::string & | fname, |
| int | depth = CV_8U |
||
| ) | const |
Saves the Texture as an image file (e.g. PNG).
| glm::ivec2 hmap::Texture::shape = glm::ivec2(0, 0) |
Shape of the texture in 2D space (x, y).