KJB
|
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>
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_histogram & | operator= (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... | |
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.
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
num_bins | the 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
num_bins | the number of bins in the histogram. This value is used to discretize each of the channels (r,g,b) |
img | the image to compute the histogram over |
|
inline |
Constructor. Constructs a color histogram by reading it from a file.
|
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
num_bins | the number of bins in the histogram. This value is used to discretize each of the channels (r,g,b) |
img | the image to compute the histogram over |
top_left_x | The 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_y | The top left y coordinate of the rectangle |
bottom_right_x | The bottom right x coordinate of the rectangle |
bottom_right_y | The bottom right y coordinate of the rectangle |
Color_histogram::Color_histogram | ( | const Color_histogram & | src | ) |
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.
|
inline |
Returns the number of bins.
|
inline |
Returns the value of the bin corresponding to the input (r,g,b) values.
|
inline |
Color_histogram & Color_histogram::operator= | ( | const Color_histogram & | src | ) |
void Color_histogram::print_human_readable | ( | std::ostream & | out | ) | const |
|
virtual |
Reads this camera from an input stream.
Implements kjb::Readable.
|
inlinevirtual |
Reads this parametric_parapiped from a file.
Reimplemented from kjb::Readable.
|
inline |
compute sum of all the bins in the histogram
|
virtual |
Writes this camera to an output stream.
Implements kjb::Writeable.
|
inlinevirtual |
Writes this camera to an output stream.
Reimplemented from kjb::Writeable.