Added/Updated/Fixed doxygen comments

This commit is contained in:
T. van der Zwan
2013-09-09 02:54:13 +00:00
parent d2d7265f02
commit 8441dd51cc
13 changed files with 385 additions and 74 deletions

View File

@@ -15,17 +15,17 @@
class ColorTransform
{
public:
/// @brief Default constructor
/// Default constructor
ColorTransform();
/// @brief Constructor
/// Constructor
/// @param threshold
/// @param gamma
/// @param blacklevel
/// @param whitelevel
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel);
/// @brief Destructor
/// Destructor
~ColorTransform();
/// @return The current threshold value
@@ -52,7 +52,7 @@ public:
/// @param whitelevel New whitelevel value
void setWhitelevel(double whitelevel);
/// @brief Transform the given byte value
/// Transform the given byte value
/// @param input The input color byte
/// @return The transformed byte value
uint8_t transform(uint8_t input) const
@@ -61,14 +61,19 @@ public:
}
private:
/// @brief (re)-initilize the color mapping
/// (re)-initilize the color mapping
void initializeMapping();
private:
/// The threshold value
double _threshold;
/// The gamma value
double _gamma;
/// The blacklevel
double _blacklevel;
/// The whitelevel
double _whitelevel;
/// The mapping from input color to output color
uint8_t _mapping[256];
};

View File

@@ -4,48 +4,79 @@
#include <cstdint>
///
/// \brief Color transformation to adjust the saturation and value of a RGB color value
/// Color transformation to adjust the saturation and value of a RGB color value
///
class HsvTransform
{
public:
///
/// Default constructor
///
HsvTransform();
/// @brief Constructor
/// @param saturationGain
/// @param valueGain
///
/// Constructor
///
/// @param saturationGain The used saturation gain
/// @param valueGain The used value gain
///
HsvTransform(double saturationGain, double valueGain);
///
/// Destructor
///
~HsvTransform();
///
/// Updates the saturation gain
///
/// @param saturationGain New saturationGain
///
void setSaturationGain(double saturationGain);
///
/// Returns the saturation gain
///
/// @return The current Saturation gain
///
double getSaturationGain() const;
/// @param valueGain New Value gain
///
/// Updates the value gain
///
/// @param valueGain New value gain
///
void setValueGain(double valueGain);
///
/// Returns the value gain
///
/// @return The current value gain
///
double getValueGain() const;
/// @brief Apply the transform the the given RGB values.
///
/// Apply the transform the the given RGB values.
///
/// @param red The red color component
/// @param green The green color component
/// @param blue The blue color component
///
/// @note The values are updated in place.
///
void transform(uint8_t & red, uint8_t & green, uint8_t & blue) const;
///
/// integer version of the conversion are faster, but a little less accurate
/// all values are unsigned 8 bit values and scaled between 0 and 255 except
/// for the hue which is a 16 bit number and scaled between 0 and 360
///
static void rgb2hsv(uint8_t red, uint8_t green, uint8_t blue, uint16_t & hue, uint8_t & saturation, uint8_t & value);
static void hsv2rgb(uint16_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue);
private:
/// The saturation gain
double _saturationGain;
/// The value gain
double _valueGain;
};

View File

@@ -8,31 +8,57 @@
// Forward class declaration
struct RgbColor;
///
/// Plain-Old-Data structure containing the red-green-blue color specification. Size of the
/// structure is exactly 3-bytes for easy writing to led-device
///
struct RgbColor
{
/// The red color channel
uint8_t red;
/// The green color channel
uint8_t green;
/// The blue color channel
uint8_t blue;
/// 'Black' RgbColor (0, 0, 0)
static RgbColor BLACK;
/// 'Red' RgbColor (255, 0, 0)
static RgbColor RED;
/// 'Green' RgbColor (0, 255, 0)
static RgbColor GREEN;
/// 'Blue' RgbColor (0, 0, 255)
static RgbColor BLUE;
/// 'Yellow' RgbColor (255, 255, 0)
static RgbColor YELLOW;
/// 'White' RgbColor (255, 255, 255)
static RgbColor WHITE;
///
/// Checks is this exactly matches another color
///
/// @param other The other color
///
/// @return True if the colors are identical
///
inline bool operator==(const RgbColor& other) const
{
return red == other.red && green == other.green && blue == other.blue;
}
};
/// Assert to ensure that the size of the structure is 'only' 3 bytes
static_assert(sizeof(RgbColor) == 3, "Incorrect size of RgbColor");
///
/// Stream operator to write RgbColor to an outputstream (format "'{'[red]','[green]','[blue]'}'")
///
/// @param os The output stream
/// @param color The color to write
/// @return The output stream (with the color written to it)
///
inline std::ostream& operator<<(std::ostream& os, const RgbColor& color)
{
os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "}";
return os;
}

View File

@@ -8,57 +8,127 @@
// Local includes
#include "RgbColor.h"
///
/// The RgbImage holds a 2D matrix of RgbColors's (or image). Width and height of the image are
/// fixed at construction.
///
class RgbImage
{
public:
///
/// Constructor for an image with specified width and height
///
/// @param width The width of the image
/// @param height The height of the image
/// @param background The color of the image (default = BLACK)
///
RgbImage(const unsigned width, const unsigned height, const RgbColor background = RgbColor::BLACK);
///
/// Destructor
///
~RgbImage();
///
/// Returns the width of the image
///
/// @return The width of the image
///
inline unsigned width() const
{
return mWidth;
return _width;
}
///
/// Returns the height of the image
///
/// @return The height of the image
///
inline unsigned height() const
{
return mHeight;
return _height;
}
///
/// Sets the color of a specific pixel in the image
///
/// @param x The x index
/// @param y The y index
/// @param color The new color
///
void setPixel(const unsigned x, const unsigned y, const RgbColor color);
///
/// Returns a const reference to a specified pixel in the image
///
/// @param x The x index
/// @param y The y index
///
/// @return const reference to specified pixel
///
const RgbColor& operator()(const unsigned x, const unsigned y) const;
///
/// Returns a reference to a specified pixel in the image
///
/// @param x The x index
/// @param y The y index
///
/// @return reference to specified pixel
///
RgbColor& operator()(const unsigned x, const unsigned y);
///
/// Copies another image into this image. The images should have exactly the same size.
///
/// @param other The image to copy into this
///
inline void copy(const RgbImage& other)
{
assert(other.mWidth == mWidth);
assert(other.mHeight == mHeight);
assert(other._width == _width);
assert(other._height == _height);
memcpy(mColors, other.mColors, mWidth*mHeight*sizeof(RgbColor));
memcpy(mColors, other.mColors, _width*_height*sizeof(RgbColor));
}
///
/// Returns a memory pointer to the first pixel in the image
/// @return The memory pointer to the first pixel
///
RgbColor* memptr()
{
return mColors;
}
///
/// Returns a const memory pointer to the first pixel in the image
/// @return The const memory pointer to the first pixel
///
const RgbColor* memptr() const
{
return mColors;
}
private:
///
/// Translate x and y coordinate to index of the underlying vector
///
/// @param x The x index
/// @param y The y index
///
/// @return The index into the underlying data-vector
///
inline unsigned toIndex(const unsigned x, const unsigned y) const
{
return y*mWidth + x;
return y*_width + x;
}
private:
const unsigned mWidth;
const unsigned mHeight;
/// The width of the image
const unsigned _width;
/// The height of the image
const unsigned _height;
/** The colors of the image */
RgbColor* mColors;