Darwin  1.10(beta)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Attributes | List of all members
drwnColourHistogram Class Reference

Specialized histogram for quantized 3-channel colour values (e.g., RGB). More...

Inheritance diagram for drwnColourHistogram:
drwnStdObjIface drwnWriteable drwnCloneable drwnTypeable

Public Member Functions

 drwnColourHistogram (double pseudoCounts=1.0, unsigned channelBits=3)
 drwnColourHistogram (const drwnColourHistogram &histogram)
 copy constructor
 ~drwnColourHistogram ()
size_t size () const
 returns histogram size
void clear ()
 clear the histogram counts
void clear (double pseudoCounts)
 clear the histogram and assign a new prior
const char * type () const
 returns object type as a string (e.g., Foo::type() { return "Foo"; })
drwnColourHistogramclone () const
 returns a copy of the class usually implemented as virtual Foo* clone() { return new Foo(*this); }
bool save (drwnXMLNode &xml) const
 write object to XML node (see also write)
bool load (drwnXMLNode &xml)
 read object from XML node (see also read)
void accumulate (unsigned char red, unsigned char green, unsigned char blue)
 accumulate an RGB colour sample More...
void accumulate (const cv::Vec3b &colour)
 accumulate a cv::Vec3b colour sample
void accumulate (const cv::Scalar &colour)
 accumulate a cv::Scalar colour sample
double probability (unsigned char red, unsigned char green, unsigned char blue) const
 return probability of an RGB colour sample
double probability (const cv::Vec3b &colour) const
 return probability of a cv::Vec3b colour sample
double probability (const cv::Scalar &colour) const
 return probability of a cv::Scalar colour sample
cv::Mat visualize () const
const double & operator[] (size_t indx) const
- Public Member Functions inherited from drwnWriteable
bool write (const char *filename) const
 write object to file (calls save)
bool read (const char *filename)
 read object from file (calls load)
void dump () const
 print object's current state to standard output (for debugging)

Protected Attributes

unsigned _channelBits
 number of bits for each colour channel
unsigned char _mask
 mask for channel bits
double _pseudoCounts
 psuedo counts for dirchelet prior
vector< double > _histogram
 the histogram counts (with interpolation)
double _totalCounts
 sum of histogram counts

Detailed Description

Specialized histogram for quantized 3-channel colour values (e.g., RGB).

The following example shows how to construct a colour histogram for all pixels in a given image: /code cv::Mat img = cv::imread("testImage.jpg", CV_LOAD_IMAGE_COLOR);

// construct histogram for the image drwnColourHistogram histogram;

for (int y = 0; y < img.rows; y++) { for (int x = 0; x < img.cols; x++) { histogram.accumulate(img.at<const Vec3b>(y, x)); } }

// display the histogram drwnShowDebuggingImage(histogram.visualize(), string("histogram"), true);

Member Function Documentation

void drwnColourHistogram::accumulate ( unsigned char  red,
unsigned char  green,
unsigned char  blue 

accumulate an RGB colour sample

interpolate between 8 neighbouring bins

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