KWStyle - itkRGBAPixel.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkRGBAPixel.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:46 $
7   Version:   $Revision: 1.4 $
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 DEF #ifndef _itkRGBAPixel_txx
18 DEF #define _itkRGBAPixel_txx
19 #include "itkRGBAPixel.h"
20 #include "itkNumericTraits.h"
21
22 namespace itk
23 {
24
25 /*
26 IND ** Assignment Operator
27 IND **/
28 template<class T>
29 RGBAPixel<T>&
30 RGBAPixel<T>
31 ::operator= (const Self& r)
32 {
33   BaseArray::operator=(r);
34   return *this;
35 }
36
37
38 /*
39 IND ** Assigment from a plain array
40 IND **/
41 template<class T>
42 RGBAPixel<T>&
43 RGBAPixel<T>
44 ::operator= (const ComponentType r[4])
45 {
46   BaseArray::operator=(r);
47   return *this;
48 }
49
50
51 /*
52 IND ** Compute luminance
53 IND **/
54 template<class T>
55 typename RGBAPixel<T>::ComponentType
56 RGBAPixel<T>
57 ::GetLuminance() const
58 {
59   const double luminance =
60 IND ****0.30  * this->GetRed()   +
61 IND ****0.59  * this->GetGreen() +
62 IND ****0.11  * this->GetBlue();
63   return static_cast<ComponentType>( luminance );
64 }
65
66
67 /**
68  * Print content to an ostream
69  */
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 SEM   os <<  c[3] ;
78   return os;
79 }
80
81
82 /**
83  * Read content from an istream
84  */
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
104

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:41PM
© Kitware Inc.