mirror of https://github.com/CGAL/cgal
Remove CGAL::Classification::RGB_Color and HSV_Color and just use CGAL::Color everywhere
This commit is contained in:
parent
4555385ac1
commit
19169d9cae
|
|
@ -36,7 +36,6 @@
|
|||
#endif
|
||||
|
||||
#include <CGAL/Classification/Cluster.h>
|
||||
#include <CGAL/Classification/Color.h>
|
||||
#include <CGAL/Classification/Evaluation.h>
|
||||
#include <CGAL/Classification/Feature_base.h>
|
||||
#include <CGAL/Classification/Feature_set.h>
|
||||
|
|
|
|||
|
|
@ -1,140 +0,0 @@
|
|||
// Copyright (c) 2017 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
// Author(s) : Simon Giraudot
|
||||
|
||||
#ifndef CGAL_CLASSIFICATION_COLOR_H
|
||||
#define CGAL_CLASSIFICATION_COLOR_H
|
||||
|
||||
#include <CGAL/license/Classification.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/int.h>
|
||||
#include <CGAL/array.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Classification {
|
||||
|
||||
/*!
|
||||
\ingroup PkgClassificationColor
|
||||
|
||||
%Color described in red/green/blue space. Each component is stored
|
||||
as an unsigned char ranging from 0 (no color) to 255 (full color).
|
||||
*/
|
||||
typedef CGAL::cpp11::array<unsigned char, 3> RGB_Color;
|
||||
/*!
|
||||
\ingroup PkgClassificationColor
|
||||
|
||||
%Color described in hue/saturation/value space. Each component is stored
|
||||
as a float:
|
||||
|
||||
- `hue` ranges from 0° to 360° (corresponding to the color tint)
|
||||
- `saturation` ranges from 0.0 (gray) to 100.0 (full saturation)
|
||||
- `value` ranges from 0.0 (black) to 100.0 (white)
|
||||
*/
|
||||
typedef CGAL::cpp11::array<float, 3> HSV_Color;
|
||||
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
inline HSV_Color rgb_to_hsv (const RGB_Color& c)
|
||||
{
|
||||
double r = (double)(c[0]) / 255.;
|
||||
double g = (double)(c[1]) / 255.;
|
||||
double b = (double)(c[2]) / 255.;
|
||||
double Cmax = (std::max) (r, (std::max) (g, b));
|
||||
double Cmin = (std::min) (r, (std::min) (g, b));
|
||||
double delta = Cmax - Cmin;
|
||||
double H = 0.;
|
||||
|
||||
if (delta != 0.)
|
||||
{
|
||||
if (Cmax == r)
|
||||
H = 60. * ((g - b) / delta);
|
||||
else if (Cmax == g)
|
||||
H = 60. * (((b - r) / delta) + 2.);
|
||||
else
|
||||
H = 60. * (((r - g) / delta) + 4.);
|
||||
}
|
||||
if (H < 0.) H += 360.;
|
||||
double S = (Cmax == 0. ? 0. : 100. * (delta / Cmax));
|
||||
double V = 100. * Cmax;
|
||||
HSV_Color out = {{ float(H), float(S), float(V) }};
|
||||
return out;
|
||||
}
|
||||
|
||||
inline RGB_Color hsv_to_rgb (const HSV_Color& c)
|
||||
{
|
||||
double h = c[0];
|
||||
double s = c[1];
|
||||
double v = c[2];
|
||||
|
||||
s /= 100.;
|
||||
v /= 100.;
|
||||
double C = v*s;
|
||||
int hh = (int)(h/60.);
|
||||
double X = C * (1-CGAL::abs (hh % 2 - 1));
|
||||
double r = 0, g = 0, b = 0;
|
||||
|
||||
if( hh>=0 && hh<1 )
|
||||
{
|
||||
r = C;
|
||||
g = X;
|
||||
}
|
||||
else if( hh>=1 && hh<2 )
|
||||
{
|
||||
r = X;
|
||||
g = C;
|
||||
}
|
||||
else if( hh>=2 && hh<3 )
|
||||
{
|
||||
g = C;
|
||||
b = X;
|
||||
}
|
||||
else if( hh>=3 && hh<4 )
|
||||
{
|
||||
g = X;
|
||||
b = C;
|
||||
}
|
||||
else if( hh>=4 && hh<5 )
|
||||
{
|
||||
r = X;
|
||||
b = C;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = C;
|
||||
b = X;
|
||||
}
|
||||
double m = v-C;
|
||||
r += m;
|
||||
g += m;
|
||||
b += m;
|
||||
r *= 255.0;
|
||||
g *= 255.0;
|
||||
b *= 255.0;
|
||||
|
||||
RGB_Color out = {{ (unsigned char)r, (unsigned char)g, (unsigned char)b }};
|
||||
return out;
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
} // namespace Classification
|
||||
} // namespace CGAL
|
||||
|
||||
|
||||
|
||||
#endif // CGAL_CLASSIFICATION_COLOR_H
|
||||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include <CGAL/Classification/Color.h>
|
||||
#include <CGAL/Classification/Feature_base.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -65,7 +64,7 @@ namespace Feature {
|
|||
`ColorMap`.
|
||||
\tparam ColorMap model of `ReadablePropertyMap` whose key
|
||||
type is the value type of the iterator of `PointRange` and value type
|
||||
is `CGAL::Classification::RGB_Color`.
|
||||
is `CGAL::Color`.
|
||||
*/
|
||||
template <typename GeomTraits, typename PointRange, typename ColorMap>
|
||||
class Color_channel : public Feature_base
|
||||
|
|
@ -82,9 +81,6 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
typedef typename Classification::RGB_Color RGB_Color;
|
||||
typedef typename Classification::HSV_Color HSV_Color;
|
||||
|
||||
const PointRange& input;
|
||||
ColorMap color_map;
|
||||
Channel m_channel;
|
||||
|
|
@ -111,8 +107,8 @@ public:
|
|||
/// \cond SKIP_IN_MANUAL
|
||||
virtual float value (std::size_t pt_index)
|
||||
{
|
||||
HSV_Color c = Classification::rgb_to_hsv (get(color_map, *(input.begin()+pt_index)));
|
||||
return c[std::size_t(m_channel)];
|
||||
cpp11::array<double, 3> c = get(color_map, *(input.begin()+pt_index)).to_hsv();
|
||||
return float(c[std::size_t(m_channel)]);
|
||||
}
|
||||
/// \endcond
|
||||
};
|
||||
|
|
|
|||
|
|
@ -153,8 +153,6 @@ public:
|
|||
typedef Classification::Feature::Verticality
|
||||
<GeomTraits> Verticality;
|
||||
typedef Classification::Feature::Eigenvalue Eigenvalue;
|
||||
|
||||
typedef typename Classification::RGB_Color RGB_Color;
|
||||
/// \endcond
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -154,8 +154,6 @@ public:
|
|||
typedef Classification::Feature::Gradient_of_feature
|
||||
<PointRange, PointMap, Neighbor_query> Gradient_of_feature;
|
||||
#endif
|
||||
|
||||
typedef typename Classification::RGB_Color RGB_Color;
|
||||
/// \endcond
|
||||
|
||||
private:
|
||||
|
|
@ -336,7 +334,7 @@ public:
|
|||
|
||||
typedef typename Default::Get<VectorMap, typename GeomTraits::Vector_3 >::type
|
||||
Vmap;
|
||||
typedef typename Default::Get<ColorMap, RGB_Color >::type
|
||||
typedef typename Default::Get<ColorMap, CGAL::Color >::type
|
||||
Cmap;
|
||||
typedef typename Default::Get<EchoMap, std::size_t >::type
|
||||
Emap;
|
||||
|
|
@ -349,7 +347,7 @@ public:
|
|||
|
||||
// Functions to remove when deprecated constructor is removed
|
||||
void generate_normal_based_features(const CGAL::Constant_property_map<Iterator, typename GeomTraits::Vector_3>&) { }
|
||||
void generate_color_based_features(const CGAL::Constant_property_map<Iterator, RGB_Color>&) { }
|
||||
void generate_color_based_features(const CGAL::Constant_property_map<Iterator, CGAL::Color>&) { }
|
||||
void generate_echo_based_features(const CGAL::Constant_property_map<Iterator, std::size_t>&) { }
|
||||
#endif
|
||||
|
||||
|
|
@ -435,7 +433,7 @@ public:
|
|||
|
||||
\tparam ColorMap model of `ReadablePropertyMap` whose key type is
|
||||
the value type of the iterator of `PointRange` and value type is
|
||||
`CGAL::Classification::RGB_Color`.
|
||||
`CGAL::Color`.
|
||||
|
||||
\param features the feature set where the features are instantiated.
|
||||
\param color_map property map to access the colors of the input points (if any).
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ typedef Classification::Point_set_feature_generator<Kernel, Point_set, Point_map
|
|||
|
||||
typedef Point_set::Vector_map Vector_map;
|
||||
typedef Point_set::Property_map<std::size_t> Size_t_map;
|
||||
typedef Point_set::Property_map<Classification::RGB_Color> Color_map;
|
||||
typedef Point_set::Property_map<CGAL::Color> Color_map;
|
||||
|
||||
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ int main (int, char**)
|
|||
normal_map = pts.normal_map();
|
||||
boost::tie (echo_map, map_added) = pts.add_property_map<std::size_t> ("echo");
|
||||
assert (map_added);
|
||||
boost::tie (color_map, map_added) = pts.add_property_map<Classification::RGB_Color> ("color");
|
||||
boost::tie (color_map, map_added) = pts.add_property_map<CGAL::Color> ("color");
|
||||
assert (map_added);
|
||||
|
||||
for (std::size_t i = 0; i < 1000; ++ i)
|
||||
|
|
@ -68,7 +68,7 @@ int main (int, char**)
|
|||
CGAL::get_default_random().get_double(),
|
||||
CGAL::get_default_random().get_double()));
|
||||
echo_map[*it] = std::size_t(CGAL::get_default_random().get_int(0, 4));
|
||||
color_map[*it] = CGAL::make_array ((unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
color_map[*it] = CGAL::Color ((unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)),
|
||||
(unsigned char)(CGAL::get_default_random().get_int(0, 255)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,12 +396,12 @@ void Cluster_classification::backup_existing_colors_and_add_new()
|
|||
{
|
||||
if (m_points->point_set()->has_colors())
|
||||
{
|
||||
m_color = m_points->point_set()->add_property_map<Color>("real_color").first;
|
||||
m_color = m_points->point_set()->add_property_map<CGAL::Color>("real_color").first;
|
||||
for (Point_set::const_iterator it = m_points->point_set()->begin();
|
||||
it != m_points->point_set()->first_selected(); ++ it)
|
||||
m_color[*it] = {{ (unsigned char)(255 * m_points->point_set()->red(*it)),
|
||||
m_color[*it] = CGAL::Color ((unsigned char)(255 * m_points->point_set()->red(*it)),
|
||||
(unsigned char)(255 * m_points->point_set()->green(*it)),
|
||||
(unsigned char)(255 * m_points->point_set()->blue(*it)) }};
|
||||
(unsigned char)(255 * m_points->point_set()->blue(*it)));
|
||||
|
||||
m_points->point_set()->remove_colors();
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ void Cluster_classification::backup_existing_colors_and_add_new()
|
|||
|
||||
void Cluster_classification::reset_colors()
|
||||
{
|
||||
if (m_color == Point_set::Property_map<Color>())
|
||||
if (m_color == Point_set::Property_map<CGAL::Color>())
|
||||
m_points->point_set()->remove_colors();
|
||||
else
|
||||
{
|
||||
|
|
@ -606,7 +606,7 @@ int Cluster_classification::real_index_color() const
|
|||
{
|
||||
int out = m_index_color;
|
||||
|
||||
if (out == 0 && m_color == Point_set::Property_map<Color>())
|
||||
if (out == 0 && m_color == Point_set::Property_map<CGAL::Color>())
|
||||
out = -1;
|
||||
return out;
|
||||
}
|
||||
|
|
@ -642,7 +642,7 @@ void Cluster_classification::compute_features (std::size_t nb_scales, float voxe
|
|||
if (normals)
|
||||
normal_map = m_points->point_set()->normal_map();
|
||||
|
||||
bool colors = (m_color != Point_set::Property_map<Color>());
|
||||
bool colors = (m_color != Point_set::Property_map<CGAL::Color>());
|
||||
|
||||
Point_set::Property_map<boost::uint8_t> echo_map;
|
||||
bool echo;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ class Cluster_classification : public Item_classification_base
|
|||
public:
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef Kernel::Vector_3 Vector_3;
|
||||
typedef CGAL::Classification::RGB_Color Color;
|
||||
|
||||
typedef Point_set::Point_map Point_map;
|
||||
typedef Point_set::Vector_map Vector_map;
|
||||
|
|
@ -382,7 +381,10 @@ class Cluster_classification : public Item_classification_base
|
|||
|
||||
std::vector<Cluster> m_clusters;
|
||||
|
||||
Point_set::Property_map<Color> m_color;
|
||||
Point_set::Property_map<unsigned char> m_red;
|
||||
Point_set::Property_map<unsigned char> m_green;
|
||||
Point_set::Property_map<unsigned char> m_blue;
|
||||
Point_set::Property_map<CGAL::Color> m_color;
|
||||
Point_set::Property_map<int> m_cluster_id;
|
||||
Point_set::Property_map<int> m_training;
|
||||
Point_set::Property_map<int> m_classif;
|
||||
|
|
|
|||
|
|
@ -327,12 +327,12 @@ void Point_set_item_classification::backup_existing_colors_and_add_new()
|
|||
{
|
||||
if (m_points->point_set()->has_colors())
|
||||
{
|
||||
m_color = m_points->point_set()->add_property_map<Color>("real_color").first;
|
||||
m_color = m_points->point_set()->add_property_map<CGAL::Color>("real_color").first;
|
||||
for (Point_set::const_iterator it = m_points->point_set()->begin();
|
||||
it != m_points->point_set()->first_selected(); ++ it)
|
||||
m_color[*it] = {{ (unsigned char)(255 * m_points->point_set()->red(*it)),
|
||||
m_color[*it] = CGAL::Color((unsigned char)(255 * m_points->point_set()->red(*it)),
|
||||
(unsigned char)(255 * m_points->point_set()->green(*it)),
|
||||
(unsigned char)(255 * m_points->point_set()->blue(*it)) }};
|
||||
(unsigned char)(255 * m_points->point_set()->blue(*it)));
|
||||
|
||||
m_points->point_set()->remove_colors();
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ void Point_set_item_classification::backup_existing_colors_and_add_new()
|
|||
|
||||
void Point_set_item_classification::reset_colors()
|
||||
{
|
||||
if (m_color == Point_set::Property_map<Color>())
|
||||
if (m_color == Point_set::Property_map<CGAL::Color>())
|
||||
m_points->point_set()->remove_colors();
|
||||
else
|
||||
{
|
||||
|
|
@ -493,7 +493,7 @@ int Point_set_item_classification::real_index_color() const
|
|||
{
|
||||
int out = m_index_color;
|
||||
|
||||
if (out == 0 && m_color == Point_set::Property_map<Color>())
|
||||
if (out == 0 && m_color == Point_set::Property_map<CGAL::Color>())
|
||||
out = -1;
|
||||
return out;
|
||||
}
|
||||
|
|
@ -532,7 +532,7 @@ void Point_set_item_classification::compute_features (std::size_t nb_scales, flo
|
|||
if (normals)
|
||||
normal_map = m_points->point_set()->normal_map();
|
||||
|
||||
bool colors = (m_color != Point_set::Property_map<Color>());
|
||||
bool colors = (m_color != Point_set::Property_map<CGAL::Color>());
|
||||
|
||||
Point_set::Property_map<boost::uint8_t> echo_map;
|
||||
bool echo;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Point_set_item_classification : public Item_classification_base
|
|||
public:
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef Kernel::Vector_3 Vector_3;
|
||||
typedef CGAL::Classification::RGB_Color Color;
|
||||
|
||||
typedef Point_set::Point_map Point_map;
|
||||
typedef Point_set::Vector_map Vector_map;
|
||||
|
|
@ -398,9 +397,12 @@ class Point_set_item_classification : public Item_classification_base
|
|||
|
||||
std::vector<Cluster> m_clusters;
|
||||
|
||||
Point_set::Property_map<unsigned char> m_red;
|
||||
Point_set::Property_map<unsigned char> m_green;
|
||||
Point_set::Property_map<unsigned char> m_blue;
|
||||
Point_set::Property_map<CGAL::Color> m_color;
|
||||
std::vector<std::vector<float> > m_label_probabilities;
|
||||
|
||||
Point_set::Property_map<Color> m_color;
|
||||
Point_set::Property_map<int> m_training;
|
||||
Point_set::Property_map<int> m_classif;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue