Orfeo Toolbox  3.16
itkRGBAPixel.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkRGBAPixel.txx,v $
5  Language: C++
6  Date: $Date: 2009-03-03 15:08:36 $
7  Version: $Revision: 1.11 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkRGBAPixel_txx
18 #define __itkRGBAPixel_txx
19 #include "itkRGBAPixel.h"
20 #include "itkNumericTraits.h"
21 
22 namespace itk
23 {
24 
28 template<class T>
29 RGBAPixel<T>&
31 ::operator= (const Self& r)
32 {
33  BaseArray::operator=(r);
34  return *this;
35 }
36 
37 
38 /*
39  * Assigment from a plain array
40  */
41 template<class T>
45 {
46  BaseArray::operator=(r);
47  return *this;
48 }
49 
50 
51 /*
52  * Compute luminance
53  */
54 template<class T>
58 {
59  const double luminance =
60  0.30 * this->GetRed() +
61  0.59 * this->GetGreen() +
62  0.11 * this->GetBlue();
63  return static_cast<ComponentType>( luminance );
64 }
65 
66 
70 template<class TComponent>
71 std::ostream &
72 operator<<(std::ostream& os,const RGBAPixel<TComponent> & c )
73 {
74  os << c[0] << " ";
75  os << c[1] << " ";
76  os << c[2] << " ";
77  os << c[3];
78  return os;
79 }
80 
81 
85 template<class TComponent>
86 std::istream &
87 operator>>(std::istream& is, RGBAPixel<TComponent> & c )
88 {
89  TComponent red;
90  TComponent green;
91  TComponent blue;
92  TComponent alpha;
93  is >> red >> green >> blue;
94  c.SetRed( red );
95  c.SetGreen( green );
96  c.SetBlue( blue );
97  c.SetAlpha( alpha );
98  return is;
99 }
100 
101 } // end namespace itk
102 
103 #endif

Generated at Sun Feb 3 2013 00:03:25 for Orfeo Toolbox with doxygen 1.8.1.1