KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::Color_histogram Class Reference

Class to compute an RGB colour histogram over an image or a rectangular portion of it. The histogram is normalized. We use the same number of bins for each of the channels (r,g,b). It is easy to extend this class so that it computes such histogram over a segment of a shape other than rectangular. More...

#include <i_color_histogram.h>

Inheritance diagram for kjb::Color_histogram:
kjb::Readable kjb::Writeable

Public Member Functions

 Color_histogram (unsigned int inum_bins=DEFAULT_COL_HIST_NUM_BINS)
 Constructor. Only memory for color histogram is allocated. More...
 
 Color_histogram (unsigned int inum_bins, const kjb::Image &img)
 Constructor. Color histogram for entire image is computed. More...
 
 Color_histogram (const char *fname)
 Constructor. Constructs a color histogram by reading it from a file. More...
 
 Color_histogram (std::istream &is)
 Constructor. Constructs a color histogram by reading it from an input stream. More...
 
 Color_histogram (unsigned int inum_bins, const Image &img, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y)
 Constructor. Color histogram for the specified portion of the image is computed. More...
 
 Color_histogram (const Color_histogram &src)
 Copy constructor. More...
 
Color_histogramoperator= (const Color_histogram &src)
 Assignment operator. More...
 
void compute_histogram (const kjb::Image &img, unsigned int inum_bins, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y)
 Computes a color histogram over the specified image region, and using the input number of bins. More...
 
void compute_histogram (const kjb::Image &img, unsigned int inum_bins)
 Computes a color histogram over the entire image, and using the input number of bins. More...
 
void compute_histogram (const kjb::Image &img)
 Computes a color histogram over the entire image, without changin the number of bins. More...
 
void compute_histogram (const kjb::Image &img, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y)
 Computes a color histogram over the specified image portion, without changin the number of bins. More...
 
unsigned int get_num_bins () const
 Returns the number of bins. More...
 
double get_value (float r, float g, float b) const
 Returns the value of the bin corresponding to the input (r,g,b) values. More...
 
double get_value (int ibin_number) const
 
void print_human_readable (std::ostream &out) const
 
double compare (const Color_histogram &ch) const
 
double sum () const
 compute sum of all the bins in the histogram More...
 
virtual void read (std::istream &in)
 Reads this camera from an input stream. More...
 
virtual void read (const char *fname)
 Reads this parametric_parapiped from a file. More...
 
virtual void write (std::ostream &out) const
 Writes this camera to an output stream. More...
 
virtual void write (const char *fname) const
 Writes this camera to an output stream. More...
 
- Public Member Functions inherited from kjb::Readable
virtual ~Readable ()
 Deletes this Readable. More...
 
- Public Member Functions inherited from kjb::Writeable
virtual ~Writeable ()
 Deletes this Writeable. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from kjb::Readable
static const char * read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':')
 Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More...
 
static const char * read_field_value (std::istream &in, const char *field_name, char separator=':')
 Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More...
 

Detailed Description

Class to compute an RGB colour histogram over an image or a rectangular portion of it. The histogram is normalized. We use the same number of bins for each of the channels (r,g,b). It is easy to extend this class so that it computes such histogram over a segment of a shape other than rectangular.

Constructor & Destructor Documentation

Color_histogram::Color_histogram ( unsigned int  inum_bins = DEFAULT_COL_HIST_NUM_BINS)

Constructor. Only memory for color histogram is allocated.

Constructor. This constructor only initializes the memory for the histogram

Parameters
num_binsthe number of bins in the histogram. This value is used to discretize each of the channels (r,g,b)
Color_histogram::Color_histogram ( unsigned int  inum_bins,
const kjb::Image img 
)

Constructor. Color histogram for entire image is computed.

Constructor. The color histogram is computed over the entire image

Parameters
num_binsthe number of bins in the histogram. This value is used to discretize each of the channels (r,g,b)
imgthe image to compute the histogram over
kjb::Color_histogram::Color_histogram ( const char *  fname)
inline

Constructor. Constructs a color histogram by reading it from a file.

kjb::Color_histogram::Color_histogram ( std::istream &  is)
inline

Constructor. Constructs a color histogram by reading it from an input stream.

Color_histogram::Color_histogram ( unsigned int  inum_bins,
const Image img,
int  top_left_x,
int  top_left_y,
int  bottom_right_x,
int  bottom_right_y 
)

Constructor. Color histogram for the specified portion of the image is computed.

Constructor. The color histogram is computed over the specified rectangular portion of the image

Parameters
num_binsthe number of bins in the histogram. This value is used to discretize each of the channels (r,g,b)
imgthe image to compute the histogram over
top_left_xThe top left x coordinate of the rectangular portion of the image to compute the histogram over. The origin of the image system is the top left corner of the image, with x increasing left to right, y increasing top to bottom
top_left_yThe top left y coordinate of the rectangle
bottom_right_xThe bottom right x coordinate of the rectangle
bottom_right_yThe bottom right y coordinate of the rectangle
Color_histogram::Color_histogram ( const Color_histogram src)

Copy constructor.

Copy constructor

Parameters
srcThe Color_histogram to copy into this one

Member Function Documentation

double Color_histogram::compare ( const Color_histogram ch) const
void Color_histogram::compute_histogram ( const kjb::Image img,
unsigned int  inum_bins,
int  top_left_x,
int  top_left_y,
int  bottom_right_x,
int  bottom_right_y 
)

Computes a color histogram over the specified image region, and using the input number of bins.

void Color_histogram::compute_histogram ( const kjb::Image img,
unsigned int  inum_bins 
)

Computes a color histogram over the entire image, and using the input number of bins.

void Color_histogram::compute_histogram ( const kjb::Image img)

Computes a color histogram over the entire image, without changin the number of bins.

void Color_histogram::compute_histogram ( const kjb::Image img,
int  top_left_x,
int  top_left_y,
int  bottom_right_x,
int  bottom_right_y 
)

Computes a color histogram over the specified image portion, without changin the number of bins.

unsigned int kjb::Color_histogram::get_num_bins ( ) const
inline

Returns the number of bins.

double kjb::Color_histogram::get_value ( float  r,
float  g,
float  b 
) const
inline

Returns the value of the bin corresponding to the input (r,g,b) values.

double kjb::Color_histogram::get_value ( int  ibin_number) const
inline
Color_histogram & Color_histogram::operator= ( const Color_histogram src)

Assignment operator.

Assignment operator

Parameters
srcThe Color_histogram to assign to this one
void Color_histogram::print_human_readable ( std::ostream &  out) const
void Color_histogram::read ( std::istream &  in)
virtual

Reads this camera from an input stream.

Implements kjb::Readable.

virtual void kjb::Color_histogram::read ( const char *  fname)
inlinevirtual

Reads this parametric_parapiped from a file.

Reimplemented from kjb::Readable.

double kjb::Color_histogram::sum ( ) const
inline

compute sum of all the bins in the histogram

void Color_histogram::write ( std::ostream &  out) const
virtual

Writes this camera to an output stream.

Implements kjb::Writeable.

virtual void kjb::Color_histogram::write ( const char *  fname) const
inlinevirtual

Writes this camera to an output stream.

Reimplemented from kjb::Writeable.


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