refinery
RAW file processor
Public Types | Public Member Functions | Static Public Attributes

refinery::Histogram< ImageType, TCoarseness > Class Template Reference

Says, for each color, how many of a picture's pixels hold each value. More...

#include <refinery/histogram.h>

Collaboration diagram for refinery::Histogram< ImageType, TCoarseness >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ImageType::ValueType ValueType
 Value type of each pixel color, for instance "unsigned short".
typedef ImageType::PixelType PixelType
 Pixel type, for instance RGBPixel<unsigned char>.
typedef ImageType::ColorType ColorType
 Color type, that is, index type.

Public Member Functions

 Histogram (const ImageType &image)
 Constructor.
unsigned int nSlots () const
 Number of distinct counting slots.
unsigned int nPixels () const
 Number of pixels in the original image.
unsigned short count (const ColorType &color, std::size_t slot) const
 Number of pixels in a particular slot.

Static Public Attributes

static const unsigned int Coarseness = TCoarseness
 Coarseness.
static const ColorType NColors = PixelType::NColors
 Number of colors per pixel.

Detailed Description

template<typename ImageType, unsigned int TCoarseness = 0>
class refinery::Histogram< ImageType, TCoarseness >

Says, for each color, how many of a picture's pixels hold each value.

The TCoarseness parameter decides to what extent pixels will be "grouped" into histogram slots. For example, a Coarseness of 3 on an unsigned short value means the histogram will have 2^13 slots, rather than 2^16 (because 16 - 3 = 13). The first green slot in the histogram will sum the number of pixels with green values from 0 to 7 (7 = 2^3 - 1). A TCoarseness of 0 makes for an exact (but sometimes slower or less handy) histogram.

Template Parameters:
ImageTypeImage instance.
TCoarsenessShrinking option. For 16-bit Image, 3 is nice.
Examples:

util/raw2ppm.cc.

Definition at line 24 of file histogram.h.


Member Typedef Documentation

template<typename ImageType, unsigned int TCoarseness = 0>
typedef ImageType::ColorType refinery::Histogram< ImageType, TCoarseness >::ColorType

Color type, that is, index type.

Definition at line 31 of file histogram.h.

template<typename ImageType, unsigned int TCoarseness = 0>
typedef ImageType::PixelType refinery::Histogram< ImageType, TCoarseness >::PixelType

Pixel type, for instance RGBPixel<unsigned char>.

Definition at line 29 of file histogram.h.

template<typename ImageType, unsigned int TCoarseness = 0>
typedef ImageType::ValueType refinery::Histogram< ImageType, TCoarseness >::ValueType

Value type of each pixel color, for instance "unsigned short".

Definition at line 27 of file histogram.h.


Constructor & Destructor Documentation

template<typename ImageType, unsigned int TCoarseness = 0>
refinery::Histogram< ImageType, TCoarseness >::Histogram ( const ImageType &  image) [inline]

Constructor.

Once the Image has been read, it is forgotten.

Parameters:
[in]imageImage to read when building this Histogram.

Definition at line 73 of file histogram.h.


Member Function Documentation

template<typename ImageType, unsigned int TCoarseness = 0>
unsigned short refinery::Histogram< ImageType, TCoarseness >::count ( const ColorType color,
std::size_t  slot 
) const [inline]

Number of pixels in a particular slot.

This is indexed by slot, not by pixel value.

Parameters:
colorColor.
slotSlot, from 0 to nSlots()-1.
Returns:
Number of pixels of the colors specified by the slot.

Definition at line 107 of file histogram.h.

template<typename ImageType, unsigned int TCoarseness = 0>
unsigned int refinery::Histogram< ImageType, TCoarseness >::nPixels ( ) const [inline]

Number of pixels in the original image.

This is useful in case we want to show, for instance, what percentage of an image's pixels fall above or below a certain threshold.

Returns:
Pixel count.

Definition at line 96 of file histogram.h.

template<typename ImageType, unsigned int TCoarseness = 0>
unsigned int refinery::Histogram< ImageType, TCoarseness >::nSlots ( ) const [inline]

Number of distinct counting slots.

For instance, if we're using a char-based ImageType and Coarseness is 0, nSlots() will return 256. If Coarseness is 1, it'll be 128; 2, 64; etc.

Returns:
Number of slots.

Definition at line 86 of file histogram.h.


Member Data Documentation

template<typename ImageType, unsigned int TCoarseness = 0>
const unsigned int refinery::Histogram< ImageType, TCoarseness >::Coarseness = TCoarseness [static]

Coarseness.

Definition at line 33 of file histogram.h.

template<typename ImageType, unsigned int TCoarseness = 0>
const ColorType refinery::Histogram< ImageType, TCoarseness >::NColors = PixelType::NColors [static]

Number of colors per pixel.

Definition at line 35 of file histogram.h.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Typedefs Enumerations Enumerator