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

#include <ossimHsiVector.h>

Public Member Functions

 ossimHsiVector (ossim_float64 h=0, ossim_float64 s=0, ossim_float64 i=0)
 
 ossimHsiVector (const ossimRgbVector &rgb)
 
 ossimHsiVector (const ossimNormRgbVector &rgb)
 
ossimHsiVectoroperator= (const ossimRgbVector &rgb)
 
ossimHsiVectoroperator= (const ossimNormRgbVector &rgb)
 
void setFromRgb (ossim_float64 r, ossim_float64 g, ossim_float64 b)
 
ossim_float64 getH () const
 
ossim_float64 getS () const
 
ossim_float64 getI () const
 
void setH (ossim_float64 H)
 
void setS (ossim_float64 S)
 
void setI (ossim_float64 I)
 
ossim_float64 clamp (ossim_float64 colorValue, ossim_float64 min=0, ossim_float64 max=1) const
 

Protected Attributes

ossim_float64 theBuf [3]
 

Friends

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

Detailed Description

Definition at line 18 of file ossimHsiVector.h.

Constructor & Destructor Documentation

◆ ossimHsiVector() [1/3]

ossimHsiVector::ossimHsiVector ( ossim_float64  h = 0,
ossim_float64  s = 0,
ossim_float64  i = 0 
)
inline

Definition at line 32 of file ossimHsiVector.h.

33  {
34  theBuf[0] = h;
35  theBuf[1] = s;
36  theBuf[2] = i;
37  }
ossim_float64 theBuf[3]

◆ ossimHsiVector() [2/3]

ossimHsiVector::ossimHsiVector ( const ossimRgbVector rgb)

Definition at line 24 of file ossimHsiVector.cpp.

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

25 {
26  setFromRgb(rgb.getR()/255.0, rgb.getG()/255.0, rgb.getB()/255.0);
27 }
unsigned char getR() const
void setFromRgb(ossim_float64 r, ossim_float64 g, ossim_float64 b)
unsigned char getB() const
unsigned char getG() const

◆ ossimHsiVector() [3/3]

ossimHsiVector::ossimHsiVector ( const ossimNormRgbVector rgb)

Definition at line 29 of file ossimHsiVector.cpp.

References ossimNormRgbVector::getB(), ossimNormRgbVector::getG(), ossimNormRgbVector::getR(), and setFromRgb().

30 {
31  setFromRgb(rgb.getR(), rgb.getG(), rgb.getB());
32 }
void setFromRgb(ossim_float64 r, ossim_float64 g, ossim_float64 b)
ossim_float64 getB() const
ossim_float64 getG() const
ossim_float64 getR() const

Member Function Documentation

◆ clamp()

ossim_float64 ossimHsiVector::clamp ( ossim_float64  colorValue,
ossim_float64  min = 0,
ossim_float64  max = 1 
) const
inline

Definition at line 53 of file ossimHsiVector.h.

References max, and min.

54  {
55  colorValue = colorValue > max? max:colorValue;
56  colorValue = colorValue < min? min:colorValue;
57 
58  return colorValue;
59  }
#define max(a, b)
Definition: auxiliary.h:76
#define min(a, b)
Definition: auxiliary.h:75

◆ getH()

ossim_float64 ossimHsiVector::getH ( ) const
inline

◆ getI()

ossim_float64 ossimHsiVector::getI ( ) const
inline

◆ getS()

ossim_float64 ossimHsiVector::getS ( ) const
inline

◆ operator=() [1/2]

ossimHsiVector & ossimHsiVector::operator= ( const ossimRgbVector rgb)

Definition at line 34 of file ossimHsiVector.cpp.

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

35 {
36  setFromRgb(rgb.getR()/255.0, rgb.getG()/255.0, rgb.getB()/255.0);
37 
38  return *this;
39 
40 }
unsigned char getR() const
void setFromRgb(ossim_float64 r, ossim_float64 g, ossim_float64 b)
unsigned char getB() const
unsigned char getG() const

◆ operator=() [2/2]

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

Definition at line 42 of file ossimHsiVector.cpp.

References ossimNormRgbVector::getB(), ossimNormRgbVector::getG(), ossimNormRgbVector::getR(), and setFromRgb().

43 {
44  setFromRgb(rgb.getR(), rgb.getG(), rgb.getB());
45 
46  return *this;
47 
48 }
void setFromRgb(ossim_float64 r, ossim_float64 g, ossim_float64 b)
ossim_float64 getB() const
ossim_float64 getG() const
ossim_float64 getR() const

◆ setFromRgb()

void ossimHsiVector::setFromRgb ( ossim_float64  r,
ossim_float64  g,
ossim_float64  b 
)

Definition at line 50 of file ossimHsiVector.cpp.

References DEG_PER_RAD, FLT_EPSILON, MIN, setH(), setI(), setS(), and theBuf.

Referenced by operator=(), and ossimHsiVector().

51 {
52  ossim_float64 sum = r + g + b;
53 
54  theBuf[2] = sum/3;
55 
56  if(theBuf[2] > FLT_EPSILON)
57  {
58  double deltaI1I2 = r - g;
59  double root = deltaI1I2*deltaI1I2 +
60  ((r-b)*(g-b));
61 
62  // compute Saturation from RGB
63  theBuf[1] = 1 - (3.0/sum)*(MIN(MIN(r,g),b));
64 
65  // compte Hue from Rgb.
66  if(root >= FLT_EPSILON)
67  {
68  theBuf[0] = acos((.5*((r-g)+(r-b)))/
69  sqrt(root))*DEG_PER_RAD;
70 
71  if(b > g)
72  {
73  theBuf[0] = 360 - theBuf[0];
74  }
75  }
76  else
77  {
78  theBuf[0] = b;
79  }
80  }
81  else
82  {
83  theBuf[0] = 0;
84  theBuf[1] = 0;
85  theBuf[2] = 0;
86  }
87 
88  setH(theBuf[0]);
89  setS(theBuf[1]);
90  setI(theBuf[2]);
91 }
ossim_float64 theBuf[3]
#define DEG_PER_RAD
double ossim_float64
void setI(ossim_float64 I)
#define FLT_EPSILON
void setH(ossim_float64 H)
void setS(ossim_float64 S)
#define MIN(x, y)

◆ setH()

void ossimHsiVector::setH ( ossim_float64  H)
inline

Definition at line 49 of file ossimHsiVector.h.

Referenced by ossimHsiRemapper::getTile(), and setFromRgb().

49 { theBuf[0] = H; }
ossim_float64 theBuf[3]

◆ setI()

void ossimHsiVector::setI ( ossim_float64  I)
inline

Definition at line 51 of file ossimHsiVector.h.

Referenced by ossimHsiRemapper::getTile(), ossimBrightnessContrastSource::processRgbTile(), and setFromRgb().

51 { theBuf[2] = I; }
ossim_float64 theBuf[3]

◆ setS()

void ossimHsiVector::setS ( ossim_float64  S)
inline

Definition at line 50 of file ossimHsiVector.h.

Referenced by ossimHsiRemapper::getTile(), and setFromRgb().

50 { theBuf[1] = S; }
ossim_float64 theBuf[3]

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 21 of file ossimHsiVector.h.

22  {
23  out << "<" << data.theBuf[0] << ", "
24  << data.theBuf[1] << ", "
25  << data.theBuf[2] << ">";
26 
27  return out;
28  }
ossim_float64 theBuf[3]

Member Data Documentation

◆ theBuf

ossim_float64 ossimHsiVector::theBuf[3]
protected

buf[0] = hue buf[1] = saturation buf[2] = intensity

Definition at line 67 of file ossimHsiVector.h.

Referenced by setFromRgb().


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