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 "highmap/array.hpp"
20#include "highmap/tensor.hpp"
22
23namespace hmap
24{
25
34
35static std::map<std::string, int> normal_map_blending_method_as_string = {
36 {"Linear", NMAP_LINEAR},
37 {"Partial derivative", NMAP_DERIVATIVE},
38 {"Unreal Developer Network", NMAP_UDN},
39 {"Unity", NMAP_UNITY},
40 {"Whiteout", NMAP_WHITEOUT},
41};
42
44{
45 float in_min = 0.0f;
46 float in_max = 1.0f;
47 float exposure = 0.0f;
48 float contrast = 1.0f;
49 float saturation = 1.0f;
50 float temperature = 0.0f;
51 float gamma = 1.f;
52 float dither_amp = 0.f;
53 bool filmic_tonemap = false;
54 bool aces_tonemap = false;
55 bool agx_tonemap = false;
56};
57
65enum Cmap : int; // highmap/colormap.hpp
66
83void apply_hillshade(Tensor &img,
84 const Array &array,
85 float vmin = 0.f,
86 float vmax = 1.f,
87 float exponent = 1.f);
88
107void apply_hillshade(std::vector<uint8_t> &img,
108 const Array &array,
109 float vmin = 0.f,
110 float vmax = 1.f,
111 float exponent = 1.f,
112 bool is_img_rgba = false);
113
115 ColorAdjust param,
116 const ComputeMode &cm);
117
139 const Array &g,
140 const Array &b,
141 const glm::vec3 &color,
142 float tolerance = 0.f);
143
160Tensor colorize(const Array &array,
161 float vmin,
162 float vmax,
163 int cmap,
164 bool hillshading,
165 bool reverse = false,
166 const Array *p_noise = nullptr);
167
186void colorize(VirtualTexture &out,
187 VirtualArray &level,
188 const ComputeMode &cm,
189 float vmin,
190 float vmax,
191 int cmap,
192 VirtualArray *p_alpha = nullptr,
193 bool reverse = false,
194 VirtualArray *p_noise = nullptr);
195
215void colorize(VirtualTexture &out,
216 VirtualArray &level,
217 const ComputeMode &cm,
218 float vmin,
219 float vmax,
220 const std::vector<float> &positions,
221 const std::vector<glm::vec3> &colormap_colors,
222 VirtualArray *p_alpha = nullptr,
223 bool reverse = false,
224 VirtualArray *p_noise = nullptr);
225
234Tensor colorize_grayscale(const Array &array);
235
245Tensor colorize_histogram(const Array &array);
246
286Tensor colorize_slope_height_heatmap(const Array &array, int cmap);
287
305Tensor colorize_vec2(const Array &array1, const Array &array2);
306
317void luminance(VirtualArray &out, VirtualTexture &tex, const ComputeMode &cm);
318
333void mix(VirtualTexture &out,
334 VirtualTexture &tex1,
335 VirtualTexture &tex2,
336 const ComputeMode &cm,
337 bool use_sqrt_avg = true);
338
339void mix(VirtualTexture &out,
340 std::vector<VirtualTexture *> &texs,
341 const ComputeMode &cm,
342 bool use_sqrt_avg = true);
343
358 VirtualTexture &nmap_base,
359 VirtualTexture &nmap_detail,
360 const ComputeMode &cm,
361 float detail_scaling,
362 NormalMapBlendingMethod blending_method);
363
364} // 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:246
void luminance(VirtualArray &out, VirtualTexture &tex, const ComputeMode &cm)
Compute luminance from a texture.
Definition colorize_virtual_array.cpp:139
void color_adjust(VirtualTexture &tex, ColorAdjust param, const ComputeMode &cm)
Definition color_adjust.cpp:26
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
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:27
@ NMAP_UDN
Definition colorize.hpp:30
@ NMAP_UNITY
Definition colorize.hpp:31
@ NMAP_WHITEOUT
Definition colorize.hpp:32
@ NMAP_DERIVATIVE
Definition colorize.hpp:29
@ NMAP_LINEAR
Definition colorize.hpp:28
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:165
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:44
float in_min
Definition colorize.hpp:45
float dither_amp
Definition colorize.hpp:52
float temperature
Definition colorize.hpp:50
float saturation
Definition colorize.hpp:49
bool agx_tonemap
Definition colorize.hpp:55
bool aces_tonemap
Definition colorize.hpp:54
float contrast
Definition colorize.hpp:48
bool filmic_tonemap
Definition colorize.hpp:53
float exposure
Definition colorize.hpp:47
float gamma
Definition colorize.hpp:51
float in_max
Definition colorize.hpp:46
Definition virtual_array.hpp:57
Definition virtual_array.hpp:69
Header file for the Tensor class.