$darkmode
VCG Library
Classes | Public Types | Static Public Member Functions | List of all members
vcg::tri::UpdateColor< MeshType > Class Template Reference

Generation and processing of per-vertex and per-face colors according to various strategy. More...

#include <vcg/complex/algorithms/update/color.h>

Classes

class  ColorAvgInfo
 

Public Types

enum  rgbChMask {
  ALL_CHANNELS = 7 , RED_CHANNEL = 4 , GREEN_CHANNEL = 2 , BLUE_CHANNEL = 1 ,
  NO_CHANNELS = 0
}
 
enum  DesaturationMethods { M_LIGHTNESS = 0 , M_LUMINOSITY = 1 , M_AVERAGE = 2 }
 
typedef MeshType::VertexType VertexType
 
typedef MeshType::VertexPointer VertexPointer
 
typedef MeshType::VertexIterator VertexIterator
 
typedef MeshType::FaceType FaceType
 
typedef MeshType::FacePointer FacePointer
 
typedef MeshType::FaceIterator FaceIterator
 
typedef MeshType::EdgeIterator EdgeIterator
 
typedef MeshType::TetraType TetraType
 
typedef MeshType::TetraPointer TetraPointer
 
typedef MeshType::TetraIterator TetraIterator
 
typedef MeshType::ScalarType ScalarType
 
typedef MeshType::CoordType CoordType
 

Static Public Member Functions

static int PerVertexConstant (MeshType &m, Color4b vs=Color4b::White, bool selected=false)
 This function colors all (or the selected) the vertices of a mesh.
 
static int PerFaceConstant (MeshType &m, Color4b vs=Color4b::White, bool selected=false)
 This function colors all (or the selected) faces of a mesh.
 
static int PerTetraConstant (MeshType &m, Color4b vs=Color4b::White, bool selected=false)
 This function colors all (or the selected) tetras of a mesh.
 
static void PerVertexFromTetra (MeshType &m)
 Transfer tetra color onto vertex color. More...
 
static void PerVertexFromFace (MeshType &m)
 Transfer face color onto vertex color. More...
 
static void PerFaceFromVertex (MeshType &m)
 Transfer vertex color onto face color Plain average of the color of the vertexes on a given face.
 
static void PerVertexQualityRamp (MeshType &m, ScalarType minq=0., ScalarType maxq=0., vcg::ColorMap cmap=vcg::ColorMap::RGB)
 This function colores all the faces of a mesh with a hue color shade dependent on the quality. More...
 
static void PerVertexQualityRampParula (MeshType &m, ScalarType minq=0., ScalarType maxq=0.)
 This function colores all the faces of a mesh with a hue color shade dependent on the quality. More...
 
static void PerTetraQualityRamp (MeshType &m, ScalarType minq=0., ScalarType maxq=0., bool selected=false, vcg::ColorMap cmap=vcg::ColorMap::RGB)
 This function colores all the faces of a mesh with a hue color shade dependent on the quality. More...
 
static void PerFaceQualityRamp (MeshType &m, ScalarType minq=0, ScalarType maxq=0, bool selected=false, vcg::ColorMap cmap=vcg::ColorMap::RGB)
 This function colores all the faces of a mesh with a hue color shade dependent on the quality. More...
 
static void PerEdgeQualityRamp (MeshType &m, ScalarType minq=0, ScalarType maxq=0, bool selected=false, vcg::ColorMap cmap=vcg::ColorMap::RGB)
 This function colores all the edges of a mesh with a hue color shade dependent on the quality. More...
 
static void PerVertexQualityGray (MeshType &m, ScalarType minq=0, ScalarType maxq=0)
 This function colores all the vertices of a mesh with a gray shade dependent on the quality. More...
 
static void PerFaceQualityGray (MeshType &m, ScalarType minq=0, ScalarType maxq=0)
 This function colores all the faces of a mesh with a gray shade dependent on the quality. More...
 
static void PerVertexBorderFlag (MeshType &m, Color4b BorderColor=Color4b::Blue, Color4b InternalColor=Color4b::White, Color4b MixColor=Color4b::Cyan)
 Color the vertexes of the mesh that are on the border. More...
 
static void PerFaceRandomConnectedComponent (MeshType &m)
 This function colores the faces of connected components of a mesh randomly. More...
 
static void PerFaceRandom (MeshType &m)
 This function colores the face of a mesh randomly. More...
 
static void PerVertexPerlinNoise (MeshType &m, CoordType period, CoordType offset=CoordType(0, 0, 0), bool onSelected=false)
 Perlin Noise. More...
 
static void PerVertexPerlinColoring (MeshType &m, ScalarType period, CoordType offset=CoordType(0, 0, 0), Color4b color1=Color4b::Black, Color4b color2=Color4b::White, bool onSelected=false)
 Perlin Color mixing. More...
 
static void PerVertexAddNoise (MeshType &m, int noiseBits, bool onSelected=false)
 Simple Noise adding function. It simply add signed noise to the color of the mesh. The noise has uniform distribution and the amplitude is +/-2^(noisebits-1).
 
static int PerVertexThresholding (MeshType &m, float threshold, const Color4b c1=Color4< unsigned char >::Black, const Color4b c2=Color4< unsigned char >::White, const bool ProcessSelected=false)
 Reduces vertex color the mesh to two colors according to a threshold.
 
static float ComputeLightness (Color4b c)
 
static int PerVertexBrightness (MeshType &m, float amount, const bool ProcessSelected=false)
 Apply the brightness filter, with the given amount, to the mesh.
 
static int PerVertexContrast (MeshType &m, float factor, const bool ProcessSelected=false)
 Apply Contrast filter to the mesh with the given contrast factor.
 
static Color4b ColorMul (Color4b c, float factor)
 
static int ValueMul (int value, float factor)
 
static int PerVertexBrightnessContrast (MeshType &m, float brightness, float contrast, const bool ProcessSelected=false)
 Apply Brightness and Contrast filter to the mesh, with the given contrast factor and brightness amount. More...
 
static Color4b ColorBrightnessContrast (Color4b c, float brightness, float contrast)
 
static int ValueBrightnessContrast (unsigned char ivalue, float brightness, float contrast)
 
static int PerVertexInvert (MeshType &m, const bool ProcessSelected=false)
 Invert the colors of the mesh. More...
 
static int PerVertexGamma (MeshType &m, float gamma, const bool ProcessSelected=false)
 Apply the gamma correction filter, with the given gamma exponet, to the mesh. More...
 
static Color4b ColorPow (Color4b c, float exponent)
 
static float ValuePow (float value, float exponent)
 
static int PerVertexLevels (MeshType &m, float gamma, float in_min, float in_max, float out_min, float out_max, unsigned char rgbMask, const bool ProcessSelected=false)
 Adjusts color levels of the mesh. More...
 
static Color4b ColorLevels (Color4b c, float gamma, float in_min, float in_max, float out_min, float out_max, unsigned char rgbMask)
 
static int ValueLevels (int value, float gamma, float in_min, float in_max, float out_min, float out_max)
 
static int PerVertexColourisation (MeshType &m, Color4b c, float intensity, const bool ProcessSelected=false)
 Colorize the mesh toward a given color. More...
 
static Color4b ColorApplyDiff (Color4b old_color, Color4b new_color, float intensity)
 
static int ValueApplyDiff (int old_value, int new_value, float intensity)
 
static int PerVertexDesaturation (MeshType &m, int method, const bool ProcessSelected=false)
 Desaturates the mesh according the a chosen desaturation method. More...
 
static Color4b ColorDesaturate (Color4b c, int method)
 
static float ComputeAvgLightness (Color4b c)
 
static float ComputeLuminosity (Color4b c)
 
static int PerVertexEqualize (MeshType &m, unsigned int rgbMask, const bool ProcessSelected=false)
 Histogram Color Equalization. More...
 
static Color4b ColorEqualize (Color4b c, int cdf_l[256], int cdf_r[256], int cdf_g[256], int cdf_b[256], unsigned int rgbMask)
 
static int ValueEqualize (int cdfValue, int cdfMin, int cdfMax)
 
static int PerVertexWhiteBalance (MeshType &m, Color4b userColor, const bool ProcessSelected=false)
 Simple white balancing filter. More...
 
static Color4b ColorWhiteBalance (Color4b c, Color4b unbalancedWhite)
 

Detailed Description

template<class MeshType>
class vcg::tri::UpdateColor< MeshType >

Generation and processing of per-vertex and per-face colors according to various strategy.

This class is used to compute per face or per vertex color with respect to a number of algorithms. There is a wide range of algorithms for processing vertex color in a \i photoshop-like mode (changing for example contrast, white balance, gamma) Basic Tools for mapping quality into a color according to standard color ramps are here.

Member Function Documentation

◆ PerEdgeQualityRamp()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerEdgeQualityRamp ( MeshType &  m,
ScalarType  minq = 0,
ScalarType  maxq = 0,
bool  selected = false,
vcg::ColorMap  cmap = vcg::ColorMap::RGB 
)
inlinestatic

This function colores all the edges of a mesh with a hue color shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerFaceQualityGray()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerFaceQualityGray ( MeshType &  m,
ScalarType  minq = 0,
ScalarType  maxq = 0 
)
inlinestatic

This function colores all the faces of a mesh with a gray shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerFaceQualityRamp()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerFaceQualityRamp ( MeshType &  m,
ScalarType  minq = 0,
ScalarType  maxq = 0,
bool  selected = false,
vcg::ColorMap  cmap = vcg::ColorMap::RGB 
)
inlinestatic

This function colores all the faces of a mesh with a hue color shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerFaceRandom()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerFaceRandom ( MeshType &  m)
inlinestatic

This function colores the face of a mesh randomly.

Note: The faux bit is used to color polygonal faces uniformly

◆ PerFaceRandomConnectedComponent()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerFaceRandomConnectedComponent ( MeshType &  m)
inlinestatic

This function colores the faces of connected components of a mesh randomly.

It require FaceFace Adjacency becouse it relies on the output of the ConnecteComponents();

◆ PerTetraQualityRamp()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerTetraQualityRamp ( MeshType &  m,
ScalarType  minq = 0.,
ScalarType  maxq = 0.,
bool  selected = false,
vcg::ColorMap  cmap = vcg::ColorMap::RGB 
)
inlinestatic

This function colores all the faces of a mesh with a hue color shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerVertexBorderFlag()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexBorderFlag ( MeshType &  m,
Color4b  BorderColor = Color4b::Blue,
Color4b  InternalColor = Color4b::White,
Color4b  MixColor = Color4b::Cyan 
)
inlinestatic

Color the vertexes of the mesh that are on the border.

It uses the information in the Vertex flags, and not necessarily any topology. So it just require that you have correctly computed the flags; one way could be the following one:

static void PerVertexBorderFlag(MeshType &m, Color4b BorderColor=Color4b::Blue, Color4b InternalColor=Color4b::White, Color4b MixColor=Color4b::Cyan)
Color the vertexes of the mesh that are on the border.
Definition: color.h:371
static void VertexBorderFromFaceBorder(MeshType &m)
Compute the PerVertex Border flag deriving it from the border flag of faces.
Definition: flag.h:428
static void FaceBorderFromFF(MeshType &m)
Compute the border flags for the faces using the Face-Face Topology.
Definition: flag.h:170
static void FaceFace(MeshType &m)
Update the Face-Face topological relation by allowing to retrieve for each face what other faces shar...
Definition: topology.h:395

◆ PerVertexBrightnessContrast()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexBrightnessContrast ( MeshType &  m,
float  brightness,
float  contrast,
const bool  ProcessSelected = false 
)
inlinestatic

Apply Brightness and Contrast filter to the mesh, with the given contrast factor and brightness amount.

Performs contrast and brightness operations on color, i.e NewValue = (OldValue - 128) * contrast + 128 + amount The result is clamped just one time after all computations; this get a more accurate result.

The formula used here is the one of GIMP.

◆ PerVertexColourisation()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexColourisation ( MeshType &  m,
Color4b  c,
float  intensity,
const bool  ProcessSelected = false 
)
inlinestatic

Colorize the mesh toward a given color.

Returns
the number of changed vertexes (the selected ones)

Colors the mesh. Color is blended to the mesh with the given intensity (0..1 ranged).

◆ PerVertexDesaturation()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexDesaturation ( MeshType &  m,
int  method,
const bool  ProcessSelected = false 
)
inlinestatic

Desaturates the mesh according the a chosen desaturation method.

Returns
the number of changed vertexes (the selected ones)

There are three possibilities

  • M_LIGHTNESS where lightness = 0.5*(Max(R,G,B)+Min(R,G,B))
  • M_LUMINOSITY where luminosity = 0.21*R+0.71*G+0.7*B
  • M_AVERAGE Plain Average

◆ PerVertexEqualize()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexEqualize ( MeshType &  m,
unsigned int  rgbMask,
const bool  ProcessSelected = false 
)
inlinestatic

Histogram Color Equalization.

Returns
the number of changed vertexes (the selected ones)

Equalize the histogram of colors. It can equalize any combination of rgb channels or it can work on lightness.

◆ PerVertexFromFace()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexFromFace ( MeshType &  m)
inlinestatic

Transfer face color onto vertex color.

Plain average of the color of the faces incident on a given vertex. No adjacency required.

◆ PerVertexFromTetra()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexFromTetra ( MeshType &  m)
inlinestatic

Transfer tetra color onto vertex color.

Plain average of the color of the tetras incident on a given vertex. No adjacency required.

◆ PerVertexGamma()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexGamma ( MeshType &  m,
float  gamma,
const bool  ProcessSelected = false 
)
inlinestatic

Apply the gamma correction filter, with the given gamma exponet, to the mesh.

Returns
the number of changed vertexes (the selected ones)

◆ PerVertexInvert()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexInvert ( MeshType &  m,
const bool  ProcessSelected = false 
)
inlinestatic

Invert the colors of the mesh.

Returns
the number of changed vertexes (the selected ones)

◆ PerVertexLevels()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexLevels ( MeshType &  m,
float  gamma,
float  in_min,
float  in_max,
float  out_min,
float  out_max,
unsigned char  rgbMask,
const bool  ProcessSelected = false 
)
inlinestatic

Adjusts color levels of the mesh.

Returns
the number of changed vertexes (the selected ones)

Adjusts color levels of the mesh. Filter can be applied to all RGB channels or to each channel separately. in_min, gamma and in_max are respectively the black point, the gray point and the white point. out_min and out_max are the output level for black and white respectively.

◆ PerVertexPerlinColoring()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexPerlinColoring ( MeshType &  m,
ScalarType  period,
CoordType  offset = CoordType(0, 0, 0),
Color4b  color1 = Color4b::Black,
Color4b  color2 = Color4b::White,
bool  onSelected = false 
)
inlinestatic

Perlin Color mixing.

Simple Perlin color mixing. Color 1 and 2 are mixed according the perlin noise function, with period and offset.

◆ PerVertexPerlinNoise()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexPerlinNoise ( MeshType &  m,
CoordType  period,
CoordType  offset = CoordType(0, 0, 0),
bool  onSelected = false 
)
inlinestatic

Perlin Noise.

Simple Perlin noise. To make things weirder each color band can have its own offset and frequency. Period is expressed in absolute terms. So as period it is meaningful could be to use something in the range of 1/10 of the bbox diag.

◆ PerVertexQualityGray()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexQualityGray ( MeshType &  m,
ScalarType  minq = 0,
ScalarType  maxq = 0 
)
inlinestatic

This function colores all the vertices of a mesh with a gray shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerVertexQualityRamp()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexQualityRamp ( MeshType &  m,
ScalarType  minq = 0.,
ScalarType  maxq = 0.,
vcg::ColorMap  cmap = vcg::ColorMap::RGB 
)
inlinestatic

This function colores all the faces of a mesh with a hue color shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerVertexQualityRampParula()

template<class MeshType >
static void vcg::tri::UpdateColor< MeshType >::PerVertexQualityRampParula ( MeshType &  m,
ScalarType  minq = 0.,
ScalarType  maxq = 0. 
)
inlinestatic

This function colores all the faces of a mesh with a hue color shade dependent on the quality.

If no range of quality is passed it is automatically computed.

◆ PerVertexWhiteBalance()

template<class MeshType >
static int vcg::tri::UpdateColor< MeshType >::PerVertexWhiteBalance ( MeshType &  m,
Color4b  userColor,
const bool  ProcessSelected = false 
)
inlinestatic

Simple white balancing filter.

Returns
the number of changed vertexes (the selected ones)

It applies a simple white balancing filter. It may works on a provided user color that is supposed to be white.


The documentation for this class was generated from the following file: