|
HighMap library (C++)
|
Tile class, to manipulate a restricted region of an heightmap (with contextual informations). More...
#include <heightmap.hpp>


Public Member Functions | |
| Tile (Vec2< int > shape, Vec2< float > shift, Vec2< float > scale, Vec4< float > bbox) | |
| Construct a new Tile object. | |
| Tile () | |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | operator= (const Array &array) |
| Assignment overloading (array). | |
| 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) values from another array. | |
| void | infos () const |
| Print some informations about the object. | |
Public Member Functions inherited from hmap::Array | |
| Array () | |
| Constructs a new Array object. | |
| Array (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. | |
| Array (Vec2< int > shape, float value) | |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array (const std::string &filename, bool flip_j=false) | |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array & | operator= (const float value) |
| Overloads the assignment operator for scalar assignment. | |
| Array & | operator*= (const float value) |
| Overloads the multiplication-assignment operator for scalar multiplication. | |
| Array & | operator*= (const Array &array) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array & | operator/= (const float value) |
| Overloads the division-assignment operator for scalar division. | |
| Array & | operator/= (const Array &array) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array & | operator+= (const float value) |
| Overloads the addition-assignment operator for scalar addition. | |
| Array & | operator+= (const Array &array) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array & | operator-= (const float value) |
| Overloads the subtraction-assignment operator for scalar subtraction. | |
| Array & | operator-= (const Array &array) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | operator* (const float value) const |
| Overloads the multiplication operator for scalar multiplication. | |
| Array | operator* (const Array &array) const |
| Overloads the multiplication operator for element-wise multiplication with another array. | |
| Array | operator/ (const float value) const |
| Overloads the division operator for scalar division. | |
| Array | operator/ (const Array &array) const |
| Overloads the division operator for element-wise division by another array. | |
| Array | operator+ (const float value) const |
| Overloads the addition operator for scalar addition. | |
| Array | operator+ (const Array &array) const |
| Overloads the addition operator for element-wise addition with another array. | |
| Array | operator- () const |
| Overloads the unary minus operator. | |
| Array | operator- (const float value) const |
| Overloads the subtraction operator for scalar subtraction. | |
| Array | operator- (const Array &array) const |
| Overloads the subtraction operator for element-wise subtraction with another array. | |
| float & | operator() (int i, int j) |
| Overloads the function call operator to access the array value at index (i, j). | |
| const float & | operator() (int i, int j) const |
| Overloads the function call operator to access the array value at index (i, j) (const version). | |
| void | argmax (float &vmax, int &i, int &j) const |
| Finds the maximum value in the array and its coordinates. | |
| std::vector< float > | col_to_vector (int j) |
| Extracts a column 'j' as a std::vector. | |
| int | count_non_zero () |
| Return the number of non-zero elements in the array. | |
| void | depose_amount_bilinear_at (int i, int j, float u, float v, float amount) |
| Distribute a value 'amount' around the four cells (i, j), (i + 1, j), (i, j + 1), (i + 1, j + 1) by "reversing" the bilinear interpolation. | |
| void | depose_amount_kernel_bilinear_at (int i, int j, float u, float v, int ir, float amount) |
| void | depose_amount_kernel_at (int i, int j, const Array &kernel, float amount) |
| Distributes a specified amount of value around the cell located at (i, j) using a 1D deposition kernel applied in both horizontal and vertical directions. | |
| void | dump (const std::string &fname="out.png") const |
| Debug tool, dump some infos and generate an output file (16bits grayscale) | |
| void | dump_histogram (const std::string &msg="") const |
| Debug tool, dump array content as an ASCII histogram to the consol. | |
| Array | extract_slice (Vec4< int > idx) const |
| Extracts a subarray defined by the slice indices {i1, i2, j1, j2} from the original array, creating a new array. Note that i2 and j2 are excluded from the slice. | |
| Array | extract_slice (int i1, int i2, int j1, int j2) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | from_file (const std::string &fname) |
| Import array data from a raw binary file. | |
| void | from_numpy (const std::string &fname) |
| Import array data from a numpy binary file. | |
| float | get_gradient_x_at (int i, int j) const |
| Calculates the gradient in the 'x' (or 'i') direction at a specified index (i, j) using a 2nd order central difference scheme. | |
| float | get_gradient_y_at (int i, int j) const |
| Calculates the gradient in the 'y' (or 'j') direction at a specified index (i, j) using a 2nd order central difference scheme. | |
| float | get_gradient_x_bilinear_at (int i, int j, float u, float v) const |
| Calculates the gradient in the 'x' (or 'i') direction at a location (x, y) near the index (i, j) using bilinear interpolation. | |
| float | get_gradient_y_bilinear_at (int i, int j, float u, float v) const |
| Calculates the gradient in the 'y' (or 'j') direction at a location (x, y) near the index (i, j) using bilinear interpolation. | |
| Vec3< float > | get_normal_at (int i, int j) const |
| Calculates the surface normal vector at the index (i, j). | |
| Vec2< int > | get_shape () |
| Retrieves the shape of the array. | |
| size_t | get_sizeof () const |
| Retrieves the number of bytes occupied by the array data. | |
| float | get_value_bicubic_at (int i, int j, float u, float v) const |
| Retrieves the array value at the location (x, y) near the index (i, j) using bicubic interpolation. | |
| float | get_value_bilinear_at (int i, int j, float u, float v) const |
| Retrieves the array value at the location (x, y) near the index (i, j) using bilinear interpolation. | |
| float | get_value_nearest (float x, float y, Vec4< float > bbox) |
| Retrieves the nearest value at the location (x, y) within a bounded domain. | |
| std::vector< float > | get_vector () const |
| Retrieves the underlying data vector. | |
| void | infos (std::string msg="") const |
| Display various information about the array. | |
| int | linear_index (int i, int j) const |
| Return the linear index corresponding to the (i, j) cell in a 2D array. | |
| Vec2< int > | linear_index_reverse (int k) const |
| Convert a linear index to its corresponding (i, j) cell coordinates. | |
| float | max () const |
| Return the value of the greatest element in the array. | |
| float | mean () const |
| Return the mean value of the elements in the array. | |
| float | min () const |
| Return the value of the smallest element in the array. | |
| void | normalize () |
| Normalize array values so that the sum of all elements is equal to 1. | |
| Vec2< float > | normalization_coeff (float vmin=0.f, float vmax=1.f) const |
| Computes normalization coefficients (a, b) such that a * array + b maps the values to the range [vmin, vmax]. | |
| void | print () const |
| Print the array values to the standard output (stdout). | |
| float | ptp () const |
| Return the peak-to-peak amplitude (i.e., the difference between the maximum and minimum values) of the array values. | |
| Array | remapped () const |
| Return an array remapped to [0, 1]. | |
| Array | resample_to_shape (Vec2< int > new_shape) const |
Return a resampled array of shape new_shape using bilinear interpolation. | |
| Array | resample_to_shape_bicubic (Vec2< int > new_shape) const |
Return a resampled array of shape new_shape using bicubic interpolation. | |
| Array | resample_to_shape_bilinear (Vec2< int > new_shape) const |
| Array | resample_to_shape_nearest (Vec2< int > new_shape) const |
Return a resampled array of shape new_shape using nearest neighbor interpolation. | |
| std::vector< float > | row_to_vector (int i) |
Return a row i as a std::vector<float>. | |
| void | set_shape (Vec2< int > new_shape) |
| Sets a new shape for the array. | |
| void | set_slice (Vec4< int > idx, float value) |
| Set the value of a slice defined by indices {i1, i2, j1, j2} to a new value. | |
| void | set_slice (Vec4< int > idx, const Array &array) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| int | size () const |
| Return the total number of elements in the array. | |
| float | std () const |
| Return the standard deviation of all array values. | |
| float | sum () const |
| Return the sum of all array values. | |
| cv::Mat | to_cv_mat () |
Converts a 2D Array to an OpenCV cv::Mat. | |
| void | to_exr (const std::string &fname) const |
| Export the array as an OpenEXR image file. | |
| void | to_file (const std::string &fname) const |
| Export the array to a raw binary file. | |
| void | to_numpy (const std::string &fname) const |
| Export the array to a numpy binary file. | |
| 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. | |
| void | to_png_grayscale (const std::string &fname, int depth=CV_8U) const |
| Export the array as a grayscale PNG image file with specified bit depth. | |
| void | to_tiff (const std::string &fname) const |
| Export the array as a TIFF image file. | |
| void | to_raw_16bit (const std::string &fname) const |
| Export the array as a 16-bit raw file for Unity terrain import. | |
| std::vector< float > | unique_values () |
| Return the unique elements of the array. | |
Public Attributes | |
| Vec2< float > | shift |
| Tile shift in each direction, assuming the global domain is a unit square. For example, if the tiling is {4, 2}, the shift of tile {3, 2} is {0.75, 0.5}. | |
| Vec2< float > | scale |
| Scale of the tile in each direction, assuming the global domain is a unit square. For example, if the tiling is {4, 2} without overlap, the scale is {0.25, 0.5}. | |
| Vec4< float > | bbox |
| Tile bounding box {xmin, xmax, ymin, ymax}. | |
Public Attributes inherited from hmap::Array | |
| Vec2< int > | shape |
| The shape of the array {ni, nj}. | |
| std::vector< float > | vector |
| The underlying data storage, a vector of size shape.x * shape.y. | |
Tile class, to manipulate a restricted region of an heightmap (with contextual informations).
| hmap::Tile::Tile | ( | Vec2< int > | shape, |
| Vec2< float > | shift, | ||
| Vec2< float > | scale, | ||
| Vec4< float > | bbox | ||
| ) |
Construct a new Tile object.
| shape | Shape. |
| shift | Shift. |
| hmap::Tile::Tile | ( | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::Tile::operator= | ( | const Array & | array | ) |
Assignment overloading (array).
| array |
Fill tile values by interpolating (bilinear) values from another array.
| array | Input array. |
Fill tile values by interpolating (bicubic) values from another array.
| array | Input array. |
Fill tile values by interpolating (bilinear) values from another array.
| array | Input array. |
Fill tile values by interpolating (nearest) values from another array.
| array | Input array. |
| void hmap::Tile::infos | ( | ) | const |
Print some informations about the object.
Tile shift in each direction, assuming the global domain is a unit square. For example, if the tiling is {4, 2}, the shift of tile {3, 2} is {0.75, 0.5}.
Scale of the tile in each direction, assuming the global domain is a unit square. For example, if the tiling is {4, 2} without overlap, the scale is {0.25, 0.5}.