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};
56
64enum Cmap : int; // highmap/colormap.hpp
65
82void apply_hillshade(Tensor &img,
83 const Array &array,
84 float vmin = 0.f,
85 float vmax = 1.f,
86 float exponent = 1.f);
87
106void apply_hillshade(std::vector<uint8_t> &img,
107 const Array &array,
108 float vmin = 0.f,
109 float vmax = 1.f,
110 float exponent = 1.f,
111 bool is_img_rgba = false);
112
114 ColorAdjust param,
115 const ComputeMode &cm);
116
133Tensor colorize(const Array &array,
134 float vmin,
135 float vmax,
136 int cmap,
137 bool hillshading,
138 bool reverse = false,
139 const Array *p_noise = nullptr);
140
159void colorize(VirtualTexture &out,
160 VirtualArray &level,
161 const ComputeMode &cm,
162 float vmin,
163 float vmax,
164 int cmap,
165 VirtualArray *p_alpha = nullptr,
166 bool reverse = false,
167 VirtualArray *p_noise = nullptr);
168
188void colorize(VirtualTexture &out,
189 VirtualArray &level,
190 const ComputeMode &cm,
191 float vmin,
192 float vmax,
193 const std::vector<float> &positions,
194 const std::vector<glm::vec3> &colormap_colors,
195 VirtualArray *p_alpha = nullptr,
196 bool reverse = false,
197 VirtualArray *p_noise = nullptr);
198
207Tensor colorize_grayscale(const Array &array);
208
218Tensor colorize_histogram(const Array &array);
219
259Tensor colorize_slope_height_heatmap(const Array &array, int cmap);
260
278Tensor colorize_vec2(const Array &array1, const Array &array2);
279
290void luminance(VirtualArray &out, VirtualTexture &tex, const ComputeMode &cm);
291
306void mix(VirtualTexture &out,
307 VirtualTexture &tex1,
308 VirtualTexture &tex2,
309 const ComputeMode &cm,
310 bool use_sqrt_avg = true);
311
312void mix(VirtualTexture &out,
313 std::vector<VirtualTexture *> &texs,
314 const ComputeMode &cm,
315 bool use_sqrt_avg = true);
316
331 VirtualTexture &nmap_base,
332 VirtualTexture &nmap_detail,
333 const ComputeMode &cm,
334 float detail_scaling,
335 NormalMapBlendingMethod blending_method);
336
337} // 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:22
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
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 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:52
Definition virtual_array.hpp:62
Header file for the Tensor class.