OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
ColorUtils.hpp File Reference
#include "libslic3r/Point.hpp"
#include "TriMesh.hpp"
#include <array>
#include <cstddef>
#include <vector>
#include <functional>
Include dependency graph for ColorUtils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Slic3r::tex2color::color_utils::ClusterParameters
struct  Slic3r::tex2color::color_utils::SmoothParameters

Namespaces

namespace  Slic3r
 |/ Copyright (c) Prusa Research 2020 - 2023 Enrico Turri @enricoturri1966 |/ |/ PrusaSlicer is released under the terms of the AGPLv3 or higher |/
namespace  Slic3r::tex2color
namespace  Slic3r::tex2color::color_utils

Typedefs

typedef std::array< std::size_t, 3 > Slic3r::tex2color::color_utils::Color
typedef std::vector< Color > Slic3r::tex2color::color_utils::ColorList
typedef std::array< double, 3 > Slic3r::tex2color::color_utils::ColorDouble
typedef std::array< std::size_t, 3 > Slic3r::tex2color::color_utils::RGB

Enumerations

enum struct  Slic3r::tex2color::color_utils::ColorDifferenceMethod : std::size_t { Slic3r::tex2color::color_utils::RGB = 0 , Slic3r::tex2color::color_utils::Lab = 1 }

Functions

double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_squared_rgb (const RGB &rgb1, const RGB &rgb2)
 Compute the squared Euclidean distance between two RGB colors.
double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_squared_rgb_double (const ColorDouble &c1, const ColorDouble &c2)
 Compute the squared Euclidean distance between two RGB colors (double precision).
double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_ciede2000 (const RGB &rgb1, const RGB &rgb2)
 Compute the CIEDE2000 color difference between two RGB colors.
double Slic3r::tex2color::color_utils::calc_rgb_color_difference_by_ciede2000_srgb01 (const ColorDouble &rgb1, const ColorDouble &rgb2)
 Compute the CIEDE2000 color difference between two sRGB colors (double precision, non-linear channels in [0,1]).
std::vector< Color > Slic3r::tex2color::color_utils::cluster_k_means (const std::vector< Color > &colors, const ClusterParameters &cluster_parameters)
 K-Means clustering algorithm that minimizes the sum of squared errors.
std::vector< Color > Slic3r::tex2color::color_utils::cluster_adaptive (const std::vector< Color > &colors, const ClusterParameters &cluster_parameters)
 Adaptive K-Means clustering that determines an appropriate number of clusters under a max color-distance constraint.
std::vector< Color > Slic3r::tex2color::color_utils::cluster_to_specified_colors (const std::vector< Color > &colors, const std::vector< Color > &specified_colors)
 Cluster a color list to a set of specified cluster centers.
bool Slic3r::tex2color::color_utils::remesh_mesh (TriMesh &mesh, std::vector< std::size_t > &face_labels, double target_edge_length_ratio)
 Remesh the mesh while preserving color boundaries.
bool Slic3r::tex2color::color_utils::is_closed (const TriMesh &tri_mesh)
 Check whether the mesh is closed (watertight).
bool Slic3r::tex2color::color_utils::smooth_region (TriMesh &tri_mesh, std::vector< std::array< std::size_t, 3 > > &face_labels, const SmoothParameters &smooth_parameters=SmoothParameters())
 Smooth region boundaries (RGB color labels).
bool Slic3r::tex2color::color_utils::smooth_region (TriMesh &tri_mesh, std::vector< std::size_t > &face_labels, const SmoothParameters &smooth_parameters=SmoothParameters())
 Smooth region boundaries (integer labels).
bool Slic3r::tex2color::color_utils::get_components (const TriMesh &mesh, const std::vector< Vec2f > &vertex_uvs, std::vector< TriMesh > &component_meshes, std::vector< std::vector< Vec2f > > &component_vertex_uvs)
 Split the mesh into connected components.
bool Slic3r::tex2color::color_utils::calc_nearest_color_id (const std::vector< RGB > &colors, const RGB &color, std::size_t &nearest_color_id)
 Find the ID of the nearest color in a color list to a given color.
bool Slic3r::tex2color::color_utils::mesh_cluster (const TriMesh &mesh, const std::vector< RGB > &cluster_centers, std::vector< RGB > &map_face_to_rgb, std::vector< std::size_t > &map_face_to_cluster_id)
 Cluster mesh face colors based on given cluster centers.

Class Documentation

◆ Slic3r::tex2color::color_utils::ClusterParameters

struct Slic3r::tex2color::color_utils::ClusterParameters
Class Members
function< bool()> cancel_callback
size_t cluster_k = 10
ColorDifferenceMethod color_difference_method = ColorDifferenceMethod::Lab
size_t max_cluster_k = 32
double max_color_distance = 25
size_t max_iter = 50

◆ Slic3r::tex2color::color_utils::SmoothParameters

struct Slic3r::tex2color::color_utils::SmoothParameters
Class Members
double smooth_weight = 0.5