21 #ifndef CVD_CONVERT_PIXEL_TYPES_H
22 #define CVD_CONVERT_PIXEL_TYPES_H
33 namespace CVD{
namespace Pixel
43 static inline void convert(
const From& from, To& to) {
44 to = scalar_convert<To,From>(from);
51 static inline void convert(
const From& from, To& to) {
52 for (
int i=0; i<N; i++)
58 static inline void convert(
const T& from, T& to) {
65 static inline void convert(
const array& from, array& to) {
66 for (
int i=0; i<N; i++)
71 template <
class Rgbish,
class Scalar>
struct CIE {
72 static inline void convert(
const Rgbish& from, Scalar& to) {
85 const double wr=0.2989959716796875, wg=0.587005615234375, wb=0.1139984130859375;
99 to = scalar_convert<Scalar,typename Pixel::Component<Rgbish>::type,
double>(wr*from.red + wg*from.green + wb*from.blue);
113 template <
class P,
class Scalar>
struct Uniform {
114 static inline void convert(
const P& from, Scalar& to) {
117 for (
unsigned int i=1; i<Pixel::Component<P>::count; i++)
123 template <
class P,
class Scalar>
struct RMS {
124 static inline void convert(
const P& from, Scalar& to) {
128 for (
unsigned int i=1; i<Pixel::Component<P>::count; i++) {
137 static inline void convert(
const P& from, Scalar& to) {
141 for (
unsigned int i=1; i<Pixel::Component<P>::count; i++) {
148 template <
class P,
class Scalar>
struct L2Norm {
149 static inline void convert(
const P& from, Scalar& to) {
153 for (
unsigned int i=1; i<Pixel::Component<P>::count; i++) {
157 to = scalar_convert<Scalar,T,double>(sqrt(sum));
162 static inline void convert(
const P& from, Scalar& to) {
166 for (
unsigned int i=1; i<Pixel::Component<P>::count; i++) {
170 to = scalar_convert<Scalar,T,double>(sum);
175 static inline void convert(
const Scalar& from, Vec& to) {
178 for (
size_t i=1; i<Pixel::Component<Vec>::count; i++)
185 to.
red = to.
green = to.
blue = scalar_convert<T, Scalar>(from);
190 template <
class A,
class B>
inline void RgbToRgb(
const A& from, B& to) {
193 to.red = scalar_convert<S,T>(from.red);
194 to.green = scalar_convert<S,T>(from.green);
195 to.blue = scalar_convert<S,T>(from.blue);
199 static inline void convert(
const A& from, B& to) {
254 template <class From, class To, class Conv=typename DefaultConversion<From,To>::type,
256 static inline void convert(
const From* from, To* to,
size_t count) {
257 for (
size_t i=0; i<count; i++)
258 Conv::convert(from[i], to[i]);
263 static inline void convert(
const T* from, T* to,
size_t count) {
264 memcpy(to, from, count*
sizeof(T));
274 static const int is = std::numeric_limits<C>::is_specialized;
279 static const int is = std::numeric_limits<C>::is_specialized;
285 static const int is = std::numeric_limits<C>::is_specialized;
291 static const int is = 1;
RgbishToRgbish< Rgba< T >, Rgb< S > > type
static void convert(const Scalar &from, Vec &to)
static const P & get(const P &pixel, size_t)
void RgbToRgb(const A &from, B &to)
static void convert(const T *from, T *to, size_t count)
T green
The green component.
static void convert(const From &from, To &to)
static void convert(const From &from, To &to)
GenericConversion< Rgb< T >, Rgb< T > > type
Replicate< S, Rgb8 > type
static void convert(const P &from, Scalar &to)
Pixel::Component< From >::type FromS
GenericConversion< Rgb8, Rgb8 > type
static void convert(const P &from, Scalar &to)
T alpha
The alpha component.
RgbishToRgbish< Rgb< T >, Rgb8 > type
static void convert(const Scalar &from, Rgba< T > &to)
static void convert(const P &from, Scalar &to)
static void convert(const Rgbish &from, Scalar &to)
static void convert(const Rgba< S > &from, Rgba< T > &to)
GenericConversion< From, To > type
RgbishToRgbish< Rgb< T >, Rgb< S > > type
Pixel::Component< To >::type ToS
static void convert(const P &from, Scalar &to)
Replicate< S, Rgb< T > > type
static void convert(const array &from, array &to)
static void convert(const P &from, Scalar &to)
GenericConversion< Rgba< T >, Rgba< T > > type
static void convert(const A &from, B &to)
RgbishToRgbish< Rgb< T >, Rgba< S > > type
RgbishToRgbish< Rgb8, Rgba< S > > type
RgbishToRgbish< Rgb8, Rgb< S > > type
static void convert(const T &from, T &to)
static void convert(const A &from, Rgba< T > &to)
RgbishToRgbish< Rgba< T >, Rgb8 > type
RgbishToRgbish< Rgba< T >, Rgba< S > > type
static void convert(const From *from, To *to, size_t count)
T blue
The blue component.