aimsdata  5.0.5
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 
42 double norm (const AimsRGB &aa);
43 double norm (const AimsRGBA &aa);
44 
45 int operator < (const AimsRGB &aa, const AimsRGB &bb);
46 int operator <= (const AimsRGB &aa, const AimsRGB &bb);
47 int operator > (const AimsRGB &aa, const AimsRGB &bb);
48 int operator >= (const AimsRGB &aa, const AimsRGB &bb);
49 
50 int operator < (const AimsRGBA &aa, const AimsRGBA &bb);
51 int operator <= (const AimsRGBA &aa, const AimsRGBA &bb);
52 int operator > (const AimsRGBA &aa, const AimsRGBA &bb);
53 int operator >= (const AimsRGBA &aa, const AimsRGBA &bb);
54 
55 // AimRGB
56 inline
57 double 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 
63 inline
64 int operator < (const AimsRGB &aa,
65  const AimsRGB &bb)
66 { return( norm(aa) < norm(bb) );
67 }
68 
69 inline
70 int operator <= (const AimsRGB &aa,
71  const AimsRGB &bb)
72 { return( norm(aa) <= norm(bb) );
73 }
74 
75 inline
76 int operator > (const AimsRGB &aa,
77  const AimsRGB &bb)
78 { return( norm(aa) > norm(bb) );
79 }
80 
81 inline
82 int operator >= (const AimsRGB &aa,
83  const AimsRGB &bb)
84 { return( norm(aa) >= norm(bb) );
85 }
86 
87 // AimRGBA
88 inline
89 double 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 
96 inline
97 int operator < (const AimsRGBA &aa,
98  const AimsRGBA &bb)
99 { return( norm(aa) < norm(bb) );
100 }
101 
102 inline
103 int operator <= (const AimsRGBA &aa,
104  const AimsRGBA &bb)
105 { return( norm(aa) <= norm(bb) );
106 }
107 
108 inline
109 int operator > (const AimsRGBA &aa,
110  const AimsRGBA &bb)
111 { return( norm(aa) > norm(bb) );
112 }
113 
114 inline
115 int operator >= (const AimsRGBA &aa,
116  const AimsRGBA &bb)
117 { return( norm(aa) >= norm(bb) );
118 }
119 
120 #endif
double norm(const AimsRGB &aa)
Definition: rgbnorm.h:57
const uint8_t & blue() const
int operator<(const AimsRGB &aa, const AimsRGB &bb)
Definition: rgbnorm.h:64
const uint8_t & red() const
const uint8_t & alpha() const
int operator>(const AimsRGB &aa, const AimsRGB &bb)
Definition: rgbnorm.h:76
const uint8_t & green() const
int operator>=(const AimsRGB &aa, const AimsRGB &bb)
Definition: rgbnorm.h:82
int operator<=(const AimsRGB &aa, const AimsRGB &bb)
Definition: rgbnorm.h:70
const uint8_t & blue() const
const uint8_t & green() const
const uint8_t & red() const