OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
ossimNormRgbVector Class Reference

#include <ossimNormRgbVector.h>

Public Member Functions

 ossimNormRgbVector (ossim_float64 r=0, ossim_float64 g=0, ossim_float64 b=0)
 
 ossimNormRgbVector (ossim_float64 grey)
 
 ossimNormRgbVector (ossim_float64 colorData[3])
 
 ossimNormRgbVector (const ossimNormRgbVector &rgb)
 
 ossimNormRgbVector (const ossimRgbVector &rgb)
 
 ossimNormRgbVector (const ossimJpegYCbCrVector &YCbCr)
 
 ossimNormRgbVector (const ossimHsiVector &hsi)
 
 ossimNormRgbVector (const ossimHsvVector &hsv)
 
 ossimNormRgbVector (const ossimCmyVector &cmy)
 
ossimNormRgbVector operator- (const ossimNormRgbVector &rgb) const
 
ossimNormRgbVector operator* (ossim_float64 t) const
 
const ossimNormRgbVectoroperator= (const ossimJpegYCbCrVector &data)
 
const ossimNormRgbVectoroperator= (const ossimHsiVector &hsi)
 
const ossimNormRgbVectoroperator= (const ossimHsvVector &hsv)
 
const ossimNormRgbVectoroperator= (const ossimCmyVector &cmy)
 
bool operator== (const ossimNormRgbVector &rgb)
 
bool operator!= (const ossimNormRgbVector &rgb)
 
ossim_float64 getR () const
 
ossim_float64 getG () const
 
ossim_float64 getB () const
 
void setR (ossim_float64 r)
 
void setG (ossim_float64 g)
 
void setB (ossim_float64 b)
 

Static Public Member Functions

static ossim_float64 clamp (ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
 

Protected Attributes

ossim_float64 theBuf [3]
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimNormRgbVector &data)
 

Detailed Description

Definition at line 21 of file ossimNormRgbVector.h.

Constructor & Destructor Documentation

◆ ossimNormRgbVector() [1/9]

ossimNormRgbVector::ossimNormRgbVector ( ossim_float64  r = 0,
ossim_float64  g = 0,
ossim_float64  b = 0 
)
inline

Definition at line 32 of file ossimNormRgbVector.h.

33  {
34  theBuf[0] = r;
35  theBuf[1] = g;
36  theBuf[2] = b;
37  }
ossim_float64 theBuf[3]

◆ ossimNormRgbVector() [2/9]

ossimNormRgbVector::ossimNormRgbVector ( ossim_float64  grey)
inline

Definition at line 38 of file ossimNormRgbVector.h.

39  {
40  theBuf[0] = grey;
41  theBuf[1] = grey;
42  theBuf[2] = grey;
43  }
ossim_float64 theBuf[3]

◆ ossimNormRgbVector() [3/9]

ossimNormRgbVector::ossimNormRgbVector ( ossim_float64  colorData[3])
inline

Definition at line 44 of file ossimNormRgbVector.h.

45  {
46  theBuf[0] = colorData[0];
47  theBuf[1] = colorData[1];
48  theBuf[2] = colorData[2];
49  }
ossim_float64 theBuf[3]

◆ ossimNormRgbVector() [4/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimNormRgbVector rgb)
inline

Definition at line 50 of file ossimNormRgbVector.h.

References theBuf.

51  {
52  theBuf[0] = rgb.theBuf[0];
53  theBuf[1] = rgb.theBuf[1];
54  theBuf[2] = rgb.theBuf[2];
55  }
ossim_float64 theBuf[3]

◆ ossimNormRgbVector() [5/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimRgbVector rgb)

Definition at line 19 of file ossimNormRgbVector.cpp.

References ossimRgbVector::getB(), ossimRgbVector::getG(), ossimRgbVector::getR(), and theBuf.

20 {
21  theBuf[0] = rgb.getR()/255.0;
22  theBuf[1] = rgb.getG()/255.0;
23  theBuf[2] = rgb.getB()/255.0;
24 }
unsigned char getR() const
unsigned char getB() const
unsigned char getG() const
ossim_float64 theBuf[3]

◆ ossimNormRgbVector() [6/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimJpegYCbCrVector YCbCr)

Definition at line 26 of file ossimNormRgbVector.cpp.

27 {
28  (*this) = YCbCr;
29 
30 }

◆ ossimNormRgbVector() [7/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimHsiVector hsi)

Definition at line 32 of file ossimNormRgbVector.cpp.

33 {
34  (*this)=hsi;
35 }

◆ ossimNormRgbVector() [8/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimHsvVector hsv)

Definition at line 37 of file ossimNormRgbVector.cpp.

38 {
39  (*this) = hsv;
40 }

◆ ossimNormRgbVector() [9/9]

ossimNormRgbVector::ossimNormRgbVector ( const ossimCmyVector cmy)

Definition at line 42 of file ossimNormRgbVector.cpp.

References ossimCmyVector::getC(), ossimCmyVector::getM(), ossimCmyVector::getY(), and theBuf.

43 {
44  theBuf[0] = 255 - cmy.getC();
45  theBuf[1] = 255 - cmy.getM();
46  theBuf[2] = 255 - cmy.getY();
47 }
ossim_uint8 getC() const
ossim_uint8 getM() const
ossim_float64 theBuf[3]
ossim_uint8 getY() const

Member Function Documentation

◆ clamp()

static ossim_float64 ossimNormRgbVector::clamp ( ossim_float64  colorValue,
ossim_float64  min = 0.0,
ossim_float64  max = 1.0 
)
inlinestatic

Definition at line 90 of file ossimNormRgbVector.h.

References max, and min.

Referenced by operator=().

91  {
92  colorValue = colorValue > max? max:colorValue;
93  colorValue = colorValue < min? min:colorValue;
94 
95  return colorValue;
96  }
#define max(a, b)
Definition: auxiliary.h:76
#define min(a, b)
Definition: auxiliary.h:75

◆ getB()

ossim_float64 ossimNormRgbVector::getB ( ) const
inline

◆ getG()

ossim_float64 ossimNormRgbVector::getG ( ) const
inline

◆ getR()

ossim_float64 ossimNormRgbVector::getR ( ) const
inline

◆ operator!=()

bool ossimNormRgbVector::operator!= ( const ossimNormRgbVector rgb)
inline

Definition at line 84 of file ossimNormRgbVector.h.

References theBuf.

85  {
86  return ( (rgb.theBuf[0] != theBuf[0])||
87  (rgb.theBuf[1] != theBuf[1])||
88  (rgb.theBuf[2] != theBuf[2]));
89  }
ossim_float64 theBuf[3]

◆ operator*()

ossimNormRgbVector ossimNormRgbVector::operator* ( ossim_float64  t) const
inline

Definition at line 67 of file ossimNormRgbVector.h.

References ossim::clamp().

68  {
69  return ossimNormRgbVector(clamp(theBuf[0]*t),
70  clamp(theBuf[1]*t),
71  clamp(theBuf[2]*t));
72  }
ossimNormRgbVector(ossim_float64 r=0, ossim_float64 g=0, ossim_float64 b=0)
static ossim_float64 clamp(ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
ossim_float64 theBuf[3]

◆ operator-()

ossimNormRgbVector ossimNormRgbVector::operator- ( const ossimNormRgbVector rgb) const
inline

Definition at line 61 of file ossimNormRgbVector.h.

References ossim::clamp(), and theBuf.

62  {
63  return ossimNormRgbVector(clamp(theBuf[0] - rgb.theBuf[0]),
64  clamp(theBuf[1] - rgb.theBuf[1]),
65  clamp(theBuf[2] - rgb.theBuf[2]));
66  }
ossimNormRgbVector(ossim_float64 r=0, ossim_float64 g=0, ossim_float64 b=0)
static ossim_float64 clamp(ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
ossim_float64 theBuf[3]

◆ operator=() [1/4]

const ossimNormRgbVector & ossimNormRgbVector::operator= ( const ossimJpegYCbCrVector data)

Definition at line 122 of file ossimNormRgbVector.cpp.

References clamp(), ossimJpegYCbCrVector::getCb(), ossimJpegYCbCrVector::getCr(), ossimJpegYCbCrVector::getY(), and theBuf.

123 {
124  theBuf[0] = clamp((YCbCr.getY() +
125  1.402 * (YCbCr.getCr()-128.0))/255.0);
126  theBuf[1] = clamp((YCbCr.getY() -
127  0.34414 *(YCbCr.getCb()-128.0) -
128  0.71414*(YCbCr.getCr()-128.0))/255.0);
129  theBuf[2] = clamp((YCbCr.getY() +
130  1.772 * ( YCbCr.getCb()-128.0))/255.0);
131 
132  return *this;
133 }
static ossim_float64 clamp(ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
ossim_float64 theBuf[3]

◆ operator=() [2/4]

const ossimNormRgbVector & ossimNormRgbVector::operator= ( const ossimHsiVector hsi)

Definition at line 135 of file ossimNormRgbVector.cpp.

References clamp(), ossimHsiVector::getH(), ossimHsiVector::getI(), ossimHsiVector::getS(), RAD_PER_DEG, and theBuf.

136 {
137  ossim_float32 h = hsi.getH();
138  ossim_float32 s = hsi.getS();
139  ossim_float32 i = hsi.getI();
140 
141  ossim_float32 r=0;
142  ossim_float32 g=0;
143  ossim_float32 b=0;
144 
145  if(h <= 120.0)
146  {
147  b = i*(1-s);
148 
149  r = i*(1 + s*cos(RAD_PER_DEG*h)/cos((60-h)*RAD_PER_DEG));
150  g = 3*i - (r+b);
151  }
152  else if(h <= 240.0)
153  {
154  h-=120;
155 
156  r = i*(1-s);
157  g = i*(1 + s*cos(RAD_PER_DEG*h)/cos((60-h)*RAD_PER_DEG));
158  b = 3*i - (r+g);
159  }
160  else if(h <= 360.0)
161  {
162  h-=240;
163 
164  g = i*(1-s);
165  b = i*(1 + s*cos(RAD_PER_DEG*h)/cos((60-h)*RAD_PER_DEG));
166  r = 3*i - (g+b);
167  }
168 
169  theBuf[0] = clamp(r);
170  theBuf[1] = clamp(g);
171  theBuf[2] = clamp(b);
172 
173  return *this;
174 }
ossim_float64 getS() const
ossim_float64 getH() const
float ossim_float32
static ossim_float64 clamp(ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
ossim_float64 getI() const
ossim_float64 theBuf[3]
#define RAD_PER_DEG

◆ operator=() [3/4]

const ossimNormRgbVector & ossimNormRgbVector::operator= ( const ossimHsvVector hsv)

Definition at line 49 of file ossimNormRgbVector.cpp.

References clamp(), ossimHsvVector::getH(), ossimHsvVector::getS(), ossimHsvVector::getV(), n, ossimHsvVector::OSSIM_HSV_UNDEFINED, and theBuf.

50 {
51  // H is given on [0, 6] or UNDEFINED. S and V are given on [0, 1].
52  // RGB are each returned on [0, 1].
53  float h = hsv.getH(), // unnormalize it
54  s = hsv.getS(),
55  v = hsv.getV();
56  float m, n, f;
57  int i;
59  {
60  theBuf[0] = clamp(v);
61  theBuf[1] = clamp(v);
62  theBuf[2] = clamp(v);
63  }
64  else
65  {
66  h*=6.0; // unnormalize h
67  i = (int)floor(h);
68  f = h - i;
69  if(!(i & 1)) f = 1 - f; // if i is even
70  m = v * (1 - s);
71  n = v * (1 - s * f);
72  switch (i)
73  {
74  case 6:
75  case 0:
76  {
77  theBuf[0] = clamp(v);
78  theBuf[1] = clamp(n);
79  theBuf[2] = clamp(m);
80  break;
81  }
82  case 1:
83  {
84  theBuf[0] = clamp(n);
85  theBuf[1] = clamp(v);
86  theBuf[2] = clamp(m);
87  break;
88  }
89  case 2:
90  {
91  theBuf[0] = clamp(m);
92  theBuf[1] = clamp(v);
93  theBuf[2] = clamp(n);
94  break;
95  }
96  case 3:
97  {
98  theBuf[0] = clamp(m);
99  theBuf[1] = clamp(n);
100  theBuf[2] = clamp(v);
101  break;
102  }
103  case 4:
104  {
105  theBuf[0] = clamp(n);
106  theBuf[1] = clamp(m);
107  theBuf[2] = clamp(v);
108  break;
109  }
110  case 5:
111  {
112  theBuf[0] = clamp(v);
113  theBuf[1] = clamp(m);
114  theBuf[2] = clamp(n);
115  break;
116  }
117  }
118  }
119  return *this;
120 }
static const float OSSIM_HSV_UNDEFINED
float getS() const
static ossim_float64 clamp(ossim_float64 colorValue, ossim_float64 min=0.0, ossim_float64 max=1.0)
os2<< "> n<< " > nendobj n
float getH() const
ossim_float64 theBuf[3]
float getV() const

◆ operator=() [4/4]

const ossimNormRgbVector & ossimNormRgbVector::operator= ( const ossimCmyVector cmy)

Definition at line 176 of file ossimNormRgbVector.cpp.

References ossimCmyVector::getC(), ossimCmyVector::getM(), ossimCmyVector::getY(), and theBuf.

177 {
178  theBuf[0] = (255 - cmy.getC())/255.0;
179  theBuf[1] = (255 - cmy.getM())/255.0;
180  theBuf[2] = (255 - cmy.getY())/255.0;
181 
182  return *this;
183 }
ossim_uint8 getC() const
ossim_uint8 getM() const
ossim_float64 theBuf[3]
ossim_uint8 getY() const

◆ operator==()

bool ossimNormRgbVector::operator== ( const ossimNormRgbVector rgb)
inline

Definition at line 78 of file ossimNormRgbVector.h.

References theBuf.

79  {
80  return ( (rgb.theBuf[0] == theBuf[0])&&
81  (rgb.theBuf[1] == theBuf[1])&&
82  (rgb.theBuf[2] == theBuf[2]));
83  }
ossim_float64 theBuf[3]

◆ setB()

void ossimNormRgbVector::setB ( ossim_float64  b)
inline

Definition at line 102 of file ossimNormRgbVector.h.

102 { theBuf[2] = b; }
ossim_float64 theBuf[3]

◆ setG()

void ossimNormRgbVector::setG ( ossim_float64  g)
inline

Definition at line 101 of file ossimNormRgbVector.h.

101 { theBuf[1] = g; }
ossim_float64 theBuf[3]

◆ setR()

void ossimNormRgbVector::setR ( ossim_float64  r)
inline

Definition at line 100 of file ossimNormRgbVector.h.

100 { theBuf[0] = r; }
ossim_float64 theBuf[3]

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimNormRgbVector data 
)
friend

Definition at line 24 of file ossimNormRgbVector.h.

25  {
26  out << "<" << data.theBuf[0] << ", "
27  << data.theBuf[1] << ", "
28  << data.theBuf[2] << ">";
29 
30  return out;
31  }
ossim_float64 theBuf[3]

Member Data Documentation

◆ theBuf

ossim_float64 ossimNormRgbVector::theBuf[3]
protected

The documentation for this class was generated from the following files: