19#include <opencv2/core.hpp>
42 glm::ivec2
shape = glm::ivec2(0, 0);
100 explicit Texture(
const std::string &fname,
bool flip_j =
false);
107 return static_cast<int>(
channels.size());
163 void set_pixel(
int i,
int j,
const glm::vec3 &color);
168 void set_pixel(
int i,
int j,
const glm::vec4 &color);
183 void remap(
float vmin = 0.f,
float vmax = 1.f);
198 std::vector<uint8_t>
to_img_8bit(
bool flip_y =
false)
const;
203 void to_png(
const std::string &fname,
int depth = CV_8U)
const;
Header file defining basic vector and matrix manipulation classes.
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
A class to represent a multi-channel texture using planar hmap::Array storage.
Definition texture.hpp:37
float min() const
Find the minimum value in all channels.
Definition texture.cpp:167
cv::Mat to_cv_mat() const
Convert the texture to an OpenCV matrix.
Definition texture.cpp:219
int num_channels() const
Get the number of channels.
Definition texture.hpp:105
glm::vec3 get_pixel3(int i, int j) const
Read 3-channel color at (i, j) as glm::vec3.
Definition texture.cpp:108
Array & operator[](size_t idx)
Access channel Array by index.
Definition texture.hpp:113
Texture()=default
Construct an empty Texture object.
std::vector< uint8_t > to_img_8bit(bool flip_y=false) const
Convert the texture to an 8-bit image represented as a vector.
Definition texture.cpp:264
float & operator()(int i, int j, int c)
Access element at (i, j) in channel c.
Definition texture.hpp:137
const Array & operator[](size_t idx) const
Definition texture.hpp:117
void to_png(const std::string &fname, int depth=CV_8U) const
Saves the Texture as an image file (e.g. PNG).
Definition texture.cpp:253
float max() const
Find the maximum value in all channels.
Definition texture.cpp:156
Texture resample_to_shape(glm::ivec2 new_shape_xy) const
Resamples the texture to a new 2D shape (x, y).
Definition texture.cpp:204
const Array & channel(size_t idx) const
Definition texture.hpp:129
void remap(float vmin=0.f, float vmax=1.f)
Remap the texture values to a new range.
Definition texture.cpp:178
std::vector< Array > channels
Vector of planar Array channels.
Definition texture.hpp:47
const float & operator()(int i, int j, int c) const
Access element at (i, j) in channel c (const).
Definition texture.hpp:145
glm::vec4 get_pixel4(int i, int j) const
Read 4-channel color at (i, j) as glm::vec4.
Definition texture.cpp:118
void set_pixel(int i, int j, const glm::vec3 &color)
Write 3-channel color at (i, j) from glm::vec3.
Definition texture.cpp:131
Array & channel(size_t idx)
Access channel Array by index.
Definition texture.hpp:125
glm::ivec2 shape
Shape of the texture in 2D space (x, y).
Definition texture.hpp:42
Definition algebra.hpp:23