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

#include <ColorImage.hh>

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

List of all members.

Public Member Functions

 ColorImage (int colors=3, clrmodel cmodel=cm_rgb, Image **images=NULL, bool isReference=false, bool isMine=false)
 ColorImage (int rows, int cols, int colors=3, clrmodel cmodel=cm_rgb)
virtual ~ColorImage (void)
Imagechannel (int num)
const Imagechannel (int num) const
void read (char const *fname)
void read (char const *fname, filetype ftype)
void write (char const *fname, bool beautify=false)
void write (char const *fname, filetype ftype, bool beautify=false)
ImageaverageImage (void)
virtual void beautify (int yoffs=0, int xoffs=0, int ysize=0, int xsize=0)
ColorImageclone (void) const
virtual void copy (ColorImage &img)
int quality (void) const
void quality (int quality)
ColorImagecrop (int yoffs, int xoffs, int ysize, int xsize) const
virtual void paste (int yoffs, int xoffs, ColorImage &img)
virtual void shift (int yoffs, int xoffs)
void fill (coeff *values, int fromY=0, int fromX=0, int toY=-1, int toX=-1)
void fill (int *values, int fromY=0, int fromX=0, int toY=-1, int toX=-1)
virtual ColorImagefitInto (int rows, int cols, int *fill=NULL, int function=0) const
virtual ColorImagefitInto (int rows, int cols, bool mirrorExtend, int function=0) const
virtual ColorImagefitInto (int rows, int cols, ExtendFunc extend, int function=0) const
virtual ColorImagefitInto (int rows, int cols, ResizeFillFunc *fillFunc, int function=0) const
virtual ColorImagescale (double factor, int function=0) const
virtual ColorImagescale (double yFactor, double xFactor, int function=0) const

Protected Member Functions

void init (Image **images=NULL, bool isReference=false, bool isMine=false)
virtual void destroy (void)

Private Attributes

int m_quality

Detailed Description

An image wrapper for bitmap images of three color components. Objects may import and export different bitmap formats, such as PPM. The color models can be changed (RGB or YUV).

Definition at line 24 of file ColorImage.hh.


Constructor & Destructor Documentation

ColorImage::ColorImage ( int  colors = 3,
clrmodel  cmodel = cm_rgb,
Image **  images = NULL,
bool  isReference = false,
bool  isMine = false 
)

Constructor. Creates objects and sets actual start values.

Parameters:
colorsthe number of colors, and therefore the array's length
cmodelthe color model
imagesan array of {colors} images to copy the channel data from
ownershipif true, only references to the images will be copied, and they will not be deleted at object destruction, else the images will be cloned and destroyed in the end
isMineif true the incoming images will not be cloned, i.e. ownership is transferred to this color image
ColorImage::ColorImage ( int  rows,
int  cols,
int  colors = 3,
clrmodel  cmodel = cm_rgb 
)

Constructor. Creates an image of a given size.

Parameters:
rowsthe number of image rows to create
colsthe number of image cols to create
colorsthe number of colors
cmodelthe color model
virtual ColorImage::~ColorImage ( void  ) [virtual]

Destructor. Frees allocated objects.


Member Function Documentation

Return a new greyscale image containing the three color channels' averages

Returns:
the new image
virtual void ColorImage::beautify ( int  yoffs = 0,
int  xoffs = 0,
int  ysize = 0,
int  xsize = 0 
) [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

Implements ColorBuffer.

Image& ColorImage::channel ( int  num) [inline]

Returns a reference to one of the color channels. {Don't change the dimensions of single channels unless you know what you're doing!}

Parameters:
numthe number of the color channel
Returns:
the color channel as a reference to an Image object

Definition at line 64 of file ColorImage.hh.

const Image& ColorImage::channel ( int  num) const [inline]

Returns a reference to one of the color channels. {Don't change the dimensions of single channels unless you know what you're doing!}

Parameters:
numthe number of the color channel
Returns:
the color channel as a reference to an Image object

Definition at line 71 of file ColorImage.hh.

ColorImage* ColorImage::clone ( void  ) const

Produce a copy of this image.

Returns:
the copy
virtual void ColorImage::copy ( ColorImage img) [virtual]

Copy all data from a source image.

Parameters:
imgthe source image
Exceptions:
invalid_argumentif the two images' number of color channels do not match
ColorImage* ColorImage::crop ( int  yoffs,
int  xoffs,
int  ysize,
int  xsize 
) const

Returns a subimage.

Parameters:
yoffsthe row where to start
xoffsthe col where to start
ysizethe vertical size
xsizethe horizontal size
Returns:
the new image
virtual void ColorImage::destroy ( void  ) [protected, virtual]

Deletes allocated objects.

Reimplemented from ColorBuffer.

void ColorImage::fill ( coeff values,
int  fromY = 0,
int  fromX = 0,
int  toY = -1,
int  toX = -1 
)

Fills an image (or regions of it) with a given value

Parameters:
valuesan array of this->colors() entries containing the the new values one per channel for the selected positions (coeff values)
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)
void ColorImage::fill ( int *  values,
int  fromY = 0,
int  fromX = 0,
int  toY = -1,
int  toX = -1 
)

Fills an image (or regions of it) with a given value

Parameters:
valuesan array of this->colors() entries containing the the new values one per channel for the selected positions (int values)
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)
virtual ColorImage* ColorImage::fitInto ( int  rows,
int  cols,
int *  fill = NULL,
int  function = 0 
) const [virtual]

Produce a scaled version of the image which just fits into the given dimensions. If the aspect ratio does not fit into the new dimensions the remaining areas can be filled with a given color or alternatively the resulting image will be smaller than the target dimensions keeping its aspect ratio.

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
rowsthe target number of rows
colsthe target number of columns
fillif not NULL it must point to an array of as many values as color channels, so that each of the image's channels has its own fill greyscale value for the remaining space (else the a smaller image size will be chosen if the aspect ratio does not match)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
virtual ColorImage* ColorImage::fitInto ( int  rows,
int  cols,
bool  mirrorExtend,
int  function = 0 
) const [virtual]

Produce a scaled version of the image which just fits into the given dimensions. If the aspect ratio does not fit into the new dimensions the remaining areas can be filled with a given color or alternatively the resulting image will be smaller than the target dimensions keeping its aspect ratio.

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
rowsthe target number of rows
colsthe target number of columns
mirrorExtendif true, the otherwise empty regions of the image are extended by a mirroring function (else the a smaller image size will be chosen if the aspect ratio does not match)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
virtual ColorImage* ColorImage::fitInto ( int  rows,
int  cols,
ExtendFunc  extend,
int  function = 0 
) const [virtual]

Produce a scaled version of the image which just fits into the given dimensions. If the aspect ratio does not fit into the new dimensions the remaining areas can be filled with a given color or alternatively the resulting image will be smaller than the target dimensions keeping its aspect ratio.

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
rowsthe target number of rows
colsthe target number of columns
extendthe type of extension function used if the aspect ratio does not match (else the a smaller image size will be chosen if the aspect ratio does not match)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
virtual ColorImage* ColorImage::fitInto ( int  rows,
int  cols,
ResizeFillFunc fillFunc,
int  function = 0 
) const [virtual]

Produce a scaled version of the image which just fits into the given dimensions. If the aspect ratio does not fit into the new dimensions the remaining areas can be filled with a given color or alternatively the resulting image will be smaller than the target dimensions keeping its aspect ratio.

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
rowsthe target number of rows
colsthe target number of columns
fillFuncif not NULL a function for filling otherwise empty regions (else the a smaller image size will be chosen if the aspect ratio does not match)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
void ColorImage::init ( Image **  images = NULL,
bool  isReference = false,
bool  isMine = false 
) [protected]

Allocate objects and set standard values.

Parameters:
imagesan array of {colors} images to copy the channel data from
isReferenceif true, only references to the images will be copied, and they will not be deleted at object destruction
isMineif true, the ownership of the incoming images will be transferred to this color image
virtual void ColorImage::paste ( int  yoffs,
int  xoffs,
ColorImage img 
) [virtual]

Inserts a subimage.

Parameters:
yoffsthe row where to start
xoffsthe col where to start
imgthe image to insert
Exceptions:
invalid_argumentif the two images' number of color channels do not match
int ColorImage::quality ( void  ) const [inline]

Return the current image quality factor.

Returns:
the current image quality factor

Definition at line 152 of file ColorImage.hh.

void ColorImage::quality ( int  quality) [inline]

Sets a new image quality factor.

Returns:
the new image quality factor

Definition at line 156 of file ColorImage.hh.

References quality().

Referenced by quality().

void ColorImage::read ( char const *  fname)

Read the image. All steps independent of the file format will be performed, like testing for file readability etc.

Exceptions:
invalid_argumentinvalid file format
ios_base::failurea read error has occured [not supported by all libraries, so eventually {invalid_argument} instead]
void ColorImage::read ( char const *  fname,
filetype  ftype 
)

Read an image. Reads an image from a file using the specified file type. Currently PGM, RAW and PFI are supported.

Exceptions:
invalid_argumentthe file type is either not supported or could not be determined from the given file name
Parameters:
fnamethe file name, if {NULL}, then {stdin}
ftypethe file type
virtual ColorImage* ColorImage::scale ( double  factor,
int  function = 0 
) const [virtual]

Produce a scaled version of the image. The aspect ratio will remain the same.

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
factorthe scale factor (>= 0, 1 for no change)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
virtual ColorImage* ColorImage::scale ( double  yFactor,
double  xFactor,
int  function = 0 
) const [virtual]

Produce a scaled version of the image. The aspect ratio depends on the two scale factors

Exceptions:
invalid_argumentthe factor is negative or the function argument is invalid
Parameters:
yFactorthe vertical scale factor (>= 0, 1 for no change)
xFactorthe horizontal scale factor (>= 0, 1 for no change)
functioninterpolation function (0: bilinear interpolation, 1: average, 2: nearest neighbour).
Returns:
a new rescaled image
virtual void ColorImage::shift ( int  yoffs,
int  xoffs 
) [virtual]

Shift an Image.

Parameters:
yoffsthe rows to shift
xoffsthe cols to shift
void ColorImage::write ( char const *  fname,
bool  beautify = false 
)

Write the image. All steps independent of the file format will be performed, like testing for file writeability etc.

Exceptions:
ios_base::failurea read error has occured [not supported by all libraries, so eventually {invalid_argument} instead]
invalid_argumentthe source image has a different number of colors than the target format allows
Parameters:
fnamethe target file name
beautifybeautify images that have not had more analysis than synthesis steps?
void ColorImage::write ( char const *  fname,
filetype  ftype,
bool  beautify = false 
)

Write an image (abstract). Writes an image to a file using the specified file type.

Parameters:
ftypethe file type
fnamethe file name, if {NULL}, then {stdout}
beautifybeautify images that have not had more analysis than synthesis steps?

Member Data Documentation

int ColorImage::m_quality [private]

The image quality (if stored in lossy format like JPG)

Definition at line 309 of file ColorImage.hh.


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