Wavelet and Image class library  1.3.2
Public Member Functions | Protected Member Functions | Protected Attributes
ColorBuffer Class Reference

#include <ColorBuffer.hh>

Inheritance diagram for ColorBuffer:
Inheritance graph
[legend]
Collaboration diagram for ColorBuffer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ColorBuffer (int xysize, int colors=3, clrmodel cmodel=cm_rgb)
virtual ~ColorBuffer (void)
virtual void swapColors (int ch1, int ch2)
clrmodel colormodel (void) const
int colors (void) const
virtual void colormodel (clrmodel model)
virtual coeff smax (void) const
virtual coeff smin (void) const
virtual int fileSize (char const *fname) const
virtual bool equals (ColorBuffer &buf) const
virtual bool epsilons (ColorBuffer &buf, coeff epsilon) const
virtual void truncate (coeff min=0, coeff max=255)
virtual void beautify (int yoffs=0, int xoffs=0, int ysize=0, int xsize=0)=0
virtual coeff averageColor (int fromY=0, int fromX=0, int toY=-1, int toX=-1)
virtual unsigned char * toPixmap (clrmodel cmodel)
int rows (void) const
int cols (void) const
int size (void) const

Protected Member Functions

void init (int colors, clrmodel cmodel=cm_rgb)
virtual void destroy (void)
virtual void valadjust (void)

Protected Attributes

clrmodel m_cmodel
int m_xsize
int m_ysize
int m_xysize
int m_colors
Image ** m_images
bool m_isReference

Detailed Description

An abstract wrapper for color images and videos.

Definition at line 21 of file ColorBuffer.hh.


Constructor & Destructor Documentation

ColorBuffer::ColorBuffer ( int  xysize,
int  colors = 3,
clrmodel  cmodel = cm_rgb 
)

Constructor. Creates objects and sets actual start values.

Parameters:
xysizethe overall size of each channel (rows * cols)
colorsthe number of colors, and therefore the array's length
cmodelthe color model
virtual ColorBuffer::~ColorBuffer ( void  ) [virtual]

Destructor. Frees allocated objects.


Member Function Documentation

virtual coeff ColorBuffer::averageColor ( int  fromY = 0,
int  fromX = 0,
int  toY = -1,
int  toX = -1 
) [virtual]

Return the average color for a rectangular region inside the image drawn from one point within and the second point just outside the region

Parameters:
fromYthe first point's row
fromXthe first point's col
toYthe second point's row (-1 if lower image border)
toXthe second point's col (-1 if right image border)
Returns:
the average color

Reimplemented in ColorVideo.

virtual void ColorBuffer::beautify ( int  yoffs = 0,
int  xoffs = 0,
int  ysize = 0,
int  xsize = 0 
) [pure virtual]

Do an intelligent kind of beautification considering previous transform steps. The original data will be overwritten, so this should only be used on clones or if the image is not going to be transformed afterwise. One region inside the image could be the low-pass subband and should thus be handled separately. If that is desired, the {ysize} and {xsize} parameters should be set to nonzero values.

Parameters:
ysizethe horizontal size of the region that should be handled separately
xsizethe vertical size of the region that should be handled separately
yoffsthe horizontal offset of the region that should be handled separately
xoffsthe vertical offset of the region that should be handled separately

Implemented in ColorVideo, and ColorImage.

clrmodel ColorBuffer::colormodel ( void  ) const [inline]

Return the current colormodel

Exceptions:
invalid_argumentnumber of colors is not 3, or unsupported format / conversion
Returns:
the colormodel

Definition at line 47 of file ColorBuffer.hh.

virtual void ColorBuffer::colormodel ( clrmodel  model) [virtual]

Convert the image to a new colormodel. Note: this operation is not completely invertable. Thus it should only be applied if no further transforms and no back-conversion are desired.

Parameters:
modelthe new colormodel ({cm_rgb} or {cm_yuv})
int ColorBuffer::colors ( void  ) const [inline]

Return the current number of colors

Returns:
the number of colors

Definition at line 50 of file ColorBuffer.hh.

int ColorBuffer::cols ( void  ) const [inline]

Return the number of columns.

Returns:
the number of columns

Definition at line 150 of file ColorBuffer.hh.

virtual void ColorBuffer::destroy ( void  ) [protected, virtual]

Deletes allocated objects.

Reimplemented in ColorVideo, and ColorImage.

virtual bool ColorBuffer::epsilons ( ColorBuffer buf,
coeff  epsilon 
) const [virtual]

Rough comparison. See if two images are similar according to a given {epsilon} (important for floating-point comparisons).

Parameters:
bufthe other {ColorBuffer} object
epsilonthe epsilon
Returns:
if both are identical: {true}, else {false}

Reimplemented in ColorVideo.

virtual bool ColorBuffer::equals ( ColorBuffer buf) const [virtual]

Compares two images. Return {true} if both are equal.

Parameters:
bufThe other {ColorBuffer} object
Returns:
if equals: {true}, else {false}

Reimplemented in ColorVideo.

virtual int ColorBuffer::fileSize ( char const *  fname) const [virtual]

Returns the size in bytes of the file on the file system.

Parameters:
fnamethe file name
Returns:
the file size
void ColorBuffer::init ( int  colors,
clrmodel  cmodel = cm_rgb 
) [protected]

Allocate objects and set standard values.

Parameters:
colorsthe number of colors
cmodelthe initial color model
int ColorBuffer::rows ( void  ) const [inline]

Return the number of rows.

Returns:
the number of rows

Definition at line 146 of file ColorBuffer.hh.

int ColorBuffer::size ( void  ) const [inline]

Return the overall size.

Returns:
the overall size

Definition at line 154 of file ColorBuffer.hh.

virtual coeff ColorBuffer::smax ( void  ) const [virtual]

Returns the maximum value. Signs will be considered.

Exceptions:
invalid_argumentempty image
Returns:
the maximum

Reimplemented in ColorVideo.

virtual coeff ColorBuffer::smin ( void  ) const [virtual]

Returns the maximum value. Signs will be considered.

Exceptions:
invalid_argumentempty image
Returns:
the maximum

Reimplemented in ColorVideo.

virtual void ColorBuffer::swapColors ( int  ch1,
int  ch2 
) [virtual]

Swap two color channels.

Exceptions:
invalid_argumentif the channel specs are out of bounds
Parameters:
ch1the first channel
ch2the second channel

Reimplemented in ColorVideo.

virtual unsigned char* ColorBuffer::toPixmap ( clrmodel  cmodel) [virtual]

Export the image for other applications. This only works if the image has three channels!

Exceptions:
invalid_argumentif the current colormodel or the one passed as parameter is unsupported.
Parameters:
cmodelthe color model in which the image is exported. Currently {cm_rgb} and {cm_yuv} are supported.
Returns:
a new buffer containing the image pixels in the format according on the cmodel parameter

Reimplemented in ColorVideo.

virtual void ColorBuffer::truncate ( coeff  min = 0,
coeff  max = 255 
) [virtual]

Do a dumb kind of beautification by just truncating values to their possible maxima depending on the image format or whatever. The original data will be overwritten, so this should only be used on clones or if the original data is not needed anymore.

Parameters:
minthe minimum allowed value
maxthe maximum allowed value

Reimplemented in ColorVideo.

virtual void ColorBuffer::valadjust ( void  ) [protected, virtual]

Adjust the coefficients to make them pixelizable.


Member Data Documentation

Definition at line 158 of file ColorBuffer.hh.

int ColorBuffer::m_colors [protected]

The number of colors

Definition at line 166 of file ColorBuffer.hh.

An array of {colors} Image objects

Definition at line 168 of file ColorBuffer.hh.

Referenced by ColorVideo::currentFrameChannel().

bool ColorBuffer::m_isReference [protected]

True if the images are references and should not be deleted.

Definition at line 170 of file ColorBuffer.hh.

int ColorBuffer::m_xsize [protected]

The number of pixel cols

Definition at line 160 of file ColorBuffer.hh.

int ColorBuffer::m_xysize [protected]

The overall number of pixels

Definition at line 164 of file ColorBuffer.hh.

int ColorBuffer::m_ysize [protected]

The number of pixel rows

Definition at line 162 of file ColorBuffer.hh.


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