HighMap library (C++)
Loading...
Searching...
No Matches
colorize.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
18#pragma once
19#include <cstdint>
20#include <map>
21#include <string>
22#include <vector>
23
24#include "highmap/array.hpp"
25#include "highmap/tensor.hpp"
28
29namespace hmap
30{
31
40
41static std::map<std::string, int> normal_map_blending_method_as_string = {
42 {"Linear", NMAP_LINEAR},
43 {"Partial derivative", NMAP_DERIVATIVE},
44 {"Unreal Developer Network", NMAP_UDN},
45 {"Unity", NMAP_UNITY},
46 {"Whiteout", NMAP_WHITEOUT},
47};
48
50{
51 float in_min = 0.0f;
52 float in_max = 1.0f;
53 float exposure = 0.0f;
54 float contrast = 1.0f;
55 float saturation = 1.0f;
56 float temperature = 0.0f;
57 float gamma = 1.f;
58 float dither_amp = 0.f;
59 bool filmic_tonemap = false;
60 bool aces_tonemap = false;
61 bool agx_tonemap = false;
62};
63
71enum Cmap : int; // highmap/colormap.hpp
72
89void apply_hillshade(Tensor &img,
90 const Array &array,
91 float vmin = 0.f,
92 float vmax = 1.f,
93 float exponent = 1.f);
94
113void apply_hillshade(std::vector<uint8_t> &img,
114 const Array &array,
115 float vmin = 0.f,
116 float vmax = 1.f,
117 float exponent = 1.f,
118 bool is_img_rgba = false);
119
139void color_adjust(Array &r,
140 Array &g,
141 Array &b,
142 ColorAdjust param,
143 glm::ivec2 dither_seed);
144
166 const Array &g,
167 const Array &b,
168 const glm::vec3 &color,
169 float tolerance = 0.f);
170
187Tensor colorize(const Array &array,
188 float vmin,
189 float vmax,
190 int cmap,
191 bool hillshading,
192 bool reverse = false,
193 const Array *p_noise = nullptr);
194
213void colorize(VirtualTexture &out,
214 VirtualArray &level,
215 const ComputeMode &cm,
216 float vmin,
217 float vmax,
218 int cmap,
219 VirtualArray *p_alpha = nullptr,
220 bool reverse = false,
221 VirtualArray *p_noise = nullptr);
222
242void colorize(VirtualTexture &out,
243 VirtualArray &level,
244 const ComputeMode &cm,
245 float vmin,
246 float vmax,
247 const std::vector<float> &positions,
248 const std::vector<glm::vec3> &colormap_colors,
249 VirtualArray *p_alpha = nullptr,
250 bool reverse = false,
251 VirtualArray *p_noise = nullptr);
252
261Tensor colorize_grayscale(const Array &array);
262
272Tensor colorize_histogram(const Array &array);
273
313Tensor colorize_slope_height_heatmap(const Array &array, int cmap);
314
332Tensor colorize_vec2(const Array &array1, const Array &array2);
333
344void luminance(VirtualArray &out, VirtualTexture &tex, const ComputeMode &cm);
345
360void mix(VirtualTexture &out,
361 VirtualTexture &tex1,
362 VirtualTexture &tex2,
363 const ComputeMode &cm,
364 bool use_sqrt_avg = true);
365
366void mix(VirtualTexture &out,
367 std::vector<VirtualTexture *> &texs,
368 const ComputeMode &cm,
369 bool use_sqrt_avg = true);
370
385 VirtualTexture &nmap_base,
386 VirtualTexture &nmap_detail,
387 const ComputeMode &cm,
388 float detail_scaling,
389 NormalMapBlendingMethod blending_method);
390
391} // namespace hmap
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-dimensional tensor.
Definition tensor.hpp:37
Definition virtual_texture.hpp:28
Definition algebra.hpp:23
void mix_normal_map(VirtualTexture &out, VirtualTexture &nmap_base, VirtualTexture &nmap_detail, const ComputeMode &cm, float detail_scaling, NormalMapBlendingMethod blending_method)
Blend two normal maps into a single output normal map.
Definition colorize_virtual_array.cpp:254
void luminance(VirtualArray &out, VirtualTexture &tex, const ComputeMode &cm)
Compute luminance from a texture.
Definition colorize_virtual_array.cpp:147
Tensor colorize(const Array &array, float vmin, float vmax, int cmap, bool hillshading, bool reverse=false, const Array *p_noise=nullptr)
Apply colorization to an array.
Definition colorize.cpp:88
Array color_match_mask(const Array &r, const Array &g, const Array &b, const glm::vec3 &color, float tolerance=0.f)
Create a mask of pixels matching a target color within a tolerance.
Definition color_match_mask.cpp:11
void apply_hillshade(Tensor &img, const Array &array, float vmin=0.f, float vmax=1.f, float exponent=1.f)
Apply hillshading to a Tensor image.
Definition colorize.cpp:22
void color_adjust(Array &r, Array &g, Array &b, ColorAdjust param, glm::ivec2 dither_seed)
Apply color correction and tonemapping to RGB arrays.
Definition color_adjust.cpp:30
Tensor colorize_vec2(const Array &array1, const Array &array2)
Combine two arrays into a colored image.
Definition colorize.cpp:237
Tensor colorize_slope_height_heatmap(const Array &array, int cmap)
Colorizes a slope height heatmap based on the gradient norms of a given array.
Definition colorize.cpp:191
Tensor colorize_grayscale(const Array &array)
Convert an array to a grayscale image.
Definition colorize.cpp:147
NormalMapBlendingMethod
Definition colorize.hpp:33
@ NMAP_UDN
Definition colorize.hpp:36
@ NMAP_UNITY
Definition colorize.hpp:37
@ NMAP_WHITEOUT
Definition colorize.hpp:38
@ NMAP_DERIVATIVE
Definition colorize.hpp:35
@ NMAP_LINEAR
Definition colorize.hpp:34
void mix(VirtualTexture &out, VirtualTexture &tex1, VirtualTexture &tex2, const ComputeMode &cm, bool use_sqrt_avg=true)
Mix two textures into an output texture.
Definition colorize_virtual_array.cpp:173
Cmap
Enumeration for different colormap types.
Definition colormaps.hpp:83
Tensor colorize_histogram(const Array &array)
Convert an array to a histogram-based grayscale image.
Definition colorize.cpp:155
Definition colorize.hpp:50
float in_min
Definition colorize.hpp:51
float dither_amp
Definition colorize.hpp:58
float temperature
Definition colorize.hpp:56
float saturation
Definition colorize.hpp:55
bool agx_tonemap
Definition colorize.hpp:61
bool aces_tonemap
Definition colorize.hpp:60
float contrast
Definition colorize.hpp:54
bool filmic_tonemap
Definition colorize.hpp:59
float exposure
Definition colorize.hpp:53
float gamma
Definition colorize.hpp:57
float in_max
Definition colorize.hpp:52
Definition virtual_array.hpp:57
Definition virtual_array.hpp:69
Header file for the Tensor class.