aimsdata 6.0.0
Neuroimaging data handling
rgbnorm.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34/*
35 * Not standard RGB/RGBA norm based operators
36 */
37#ifndef AIMS_RGB_RGBNORM_H
38#define AIMS_RGB_RGBNORM_H
39
40#include <aims/rgb/rgb.h>
41
42double norm (const AimsRGB &aa);
43double norm (const AimsRGBA &aa);
44
45int operator < (const AimsRGB &aa, const AimsRGB &bb);
46int operator <= (const AimsRGB &aa, const AimsRGB &bb);
47int operator > (const AimsRGB &aa, const AimsRGB &bb);
48int operator >= (const AimsRGB &aa, const AimsRGB &bb);
49
50int operator < (const AimsRGBA &aa, const AimsRGBA &bb);
51int operator <= (const AimsRGBA &aa, const AimsRGBA &bb);
52int operator > (const AimsRGBA &aa, const AimsRGBA &bb);
53int operator >= (const AimsRGBA &aa, const AimsRGBA &bb);
54
55// AimRGB
56inline
57double norm (const AimsRGB &aa )
58{ return( sqrt( (int)aa.red() * (int)aa.red()
59 + (int)aa.green() * (int)aa.green()
60 + (int)aa.blue() * (int)aa.blue() ) );
61}
62
63inline
64int operator < (const AimsRGB &aa,
65 const AimsRGB &bb)
66{ return( norm(aa) < norm(bb) );
67}
68
69inline
70int operator <= (const AimsRGB &aa,
71 const AimsRGB &bb)
72{ return( norm(aa) <= norm(bb) );
73}
74
75inline
76int operator > (const AimsRGB &aa,
77 const AimsRGB &bb)
78{ return( norm(aa) > norm(bb) );
79}
80
81inline
82int operator >= (const AimsRGB &aa,
83 const AimsRGB &bb)
84{ return( norm(aa) >= norm(bb) );
85}
86
87// AimRGBA
88inline
89double norm (const AimsRGBA &aa )
90{ return( sqrt( (int)aa.red() * (int)aa.red()
91 + (int)aa.green() * (int)aa.green()
92 + (int)aa.blue() * (int)aa.blue()
93 + (int)aa.alpha() * (int)aa.alpha() ) );
94}
95
96inline
97int operator < (const AimsRGBA &aa,
98 const AimsRGBA &bb)
99{ return( norm(aa) < norm(bb) );
100}
101
102inline
103int operator <= (const AimsRGBA &aa,
104 const AimsRGBA &bb)
105{ return( norm(aa) <= norm(bb) );
106}
107
108inline
109int operator > (const AimsRGBA &aa,
110 const AimsRGBA &bb)
111{ return( norm(aa) > norm(bb) );
112}
113
114inline
115int operator >= (const AimsRGBA &aa,
116 const AimsRGBA &bb)
117{ return( norm(aa) >= norm(bb) );
118}
119
120#endif
const uint8_t & alpha() const
const uint8_t & blue() const
const uint8_t & red() const
const uint8_t & green() const
const uint8_t & red() const
const uint8_t & green() const
const uint8_t & blue() const
carto::VoxelRGBA AimsRGBA
Definition rgb.h:44
carto::VoxelRGB AimsRGB
Definition rgb.h:43
int operator>=(const AimsRGB &aa, const AimsRGB &bb)
Definition rgbnorm.h:82
int operator>(const AimsRGB &aa, const AimsRGB &bb)
Definition rgbnorm.h:76
int operator<(const AimsRGB &aa, const AimsRGB &bb)
Definition rgbnorm.h:64
int operator<=(const AimsRGB &aa, const AimsRGB &bb)
Definition rgbnorm.h:70
double norm(const AimsRGB &aa)
Definition rgbnorm.h:57