Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

fl::Image Class Reference

#include <image.h>

Inheritance diagram for fl::Image:

fl::CanvasImage fl::ConvolutionDiscrete1D fl::ConvolutionDiscrete2D fl::ImageOf< T > fl::Gaussian1D fl::GaussianDerivative1D fl::GaussianDerivativeSecond1D fl::DifferenceOfGaussians fl::Gaussian2D fl::GaussianDerivativeFirst fl::GaussianDerivativeSecond fl::GaussianDerivativeThird fl::Laplacian List of all members.

Public Methods

 Image ()
 Creates a new image of GrayChar, but with no buffer memory allocated.

 Image (const PixelFormat &format)
 Same as above, but with given PixelFormat.

 Image (int width, int height)
 Allocates buffer of size width x height x GrayChar.depth bytes.

 Image (int width, int height, const PixelFormat &format)
 Same as above, but with given PixelFormat.

 Image (const Image &that)
 Points our buffer to same location as "that" and copies all of its metadata.

 Image (unsigned char *buffer, int width, int height, const PixelFormat &format)
 Binds to an external block of memory.

 Image (const std::string &fileName)
 Create image initialized with contents of file.

void read (const std::string &fileName)
 Read image from fileName. Format will be determined automatically.

void read (std::istream &stream)
void write (const std::string &fileName, const std::string &formatName="pgm") const
 Write image to fileName.

void write (std::ostream &stream, const std::string &formatName="pgm") const
Image & operator<<= (const Image &that)
 Direct assignment by shallow copy. Same semantics as "=". By using a different operator than "=", we allow subclasses to inherit this function.

void copyFrom (const Image &that)
 Duplicates another Image. Copy all raster info into private buffer, and copy all other metadata.

void copyFrom (unsigned char *buffer, int width, int height, const PixelFormat &format)
 Copy from a non-Image source. Determine size of buffer in bytes as width x height x depth.

void attach (unsigned char *buffer, int width, int height, const PixelFormat &format)
 Binds to an external block of memory.

void detach ()
 Set the state of this image as if it has no buffer. Releases (but only frees if appropriate) any memory.

void resize (int width, int height)
 Changes image to new size. Any pixels that are still visible are aligned correctly. Any newly exposed pixels are set to black.

void bitblt (const Image &that, int toX=0, int toY=0, int fromX=0, int fromY=0, int width=-1, int height=-1)
 -1 for width or height means "maximum possible value"

void clear (unsigned int rgba=0)
 Initialize buffer, if it exists, to given color. In case rgba == 0, simply zeroes out memory, since this generally results in black in most pixel formats.

Image operator+ (const Image &that)
 Creates an image that sums pixel values from this and that.

Image operator- (const Image &that)
 Creates an image whose pixels are the difference between this and that.

Image operator * (double factor)
 Creates an image containing this images's pixels scaled by factor. Ie: factor == 1 -> no change; factor == 2 -> bright spots are twice as bright, and dark spots (negative values relative to bias) are twice as dark.

Image & operator *= (double factor)
 Scales each pixel by factor.

Image & operator+= (double value)
 Adds value to each pixel.

Pixel operator() (int x, int y) const
 Returns a Pixel object that wraps (x,y).

unsigned int getRGBA (int x, int y) const
 The "RGB" functions are intended for abstract access to the buffer. They perform conversion to whatever the buffer's format is.

void getRGBA (int x, int y, float values[]) const
unsigned int getYUV (int x, int y) const
unsigned char getGray (int x, int y) const
void getGray (int x, int y, float &gray) const
unsigned char getAlpha (int x, int y) const
void setRGBA (int x, int y, unsigned int rgba)
 The "rgb" format is always 24-bit RGB, 8 bits per field. Blue is in the least significant byte, then green, then red.

void setRGBA (int x, int y, float values[])
void setYUV (int x, int y, unsigned int yuv)
void setGray (int x, int y, unsigned char gray)
void setGray (int x, int y, float gray)
void setAlpha (int x, int y, unsigned char alpha)

Public Attributes

Pointer buffer
const PixelFormatformat
int width
 The Image class guarantees that width * height is always non-negative and that the raster stored in buffer has enough allocated memory to contain width * height pixels. (Of course, you can set this field directly, in which case the warranty is void. :).

int height
 See width for interface guarantees.

double timestamp
 Time when image was captured. If part of a video, then time when image should be displayed.


Constructor & Destructor Documentation

Image::Image  
 

Creates a new image of GrayChar, but with no buffer memory allocated.

Image::Image const PixelFormat   format
 

Same as above, but with given PixelFormat.

Image::Image int    width,
int    height
 

Allocates buffer of size width x height x GrayChar.depth bytes.

Image::Image int    width,
int    height,
const PixelFormat   format
 

Same as above, but with given PixelFormat.

Image::Image const Image &    that
 

Points our buffer to same location as "that" and copies all of its metadata.

Image::Image unsigned char *    buffer,
int    width,
int    height,
const PixelFormat   format
 

Binds to an external block of memory.

Image::Image const std::string &    fileName
 

Create image initialized with contents of file.


Member Function Documentation

void Image::attach unsigned char *    buffer,
int    width,
int    height,
const PixelFormat   format
 

Binds to an external block of memory.

void Image::bitblt const Image &    that,
int    toX = 0,
int    toY = 0,
int    fromX = 0,
int    fromY = 0,
int    width = -1,
int    height = -1
 

-1 for width or height means "maximum possible value"

void Image::clear unsigned int    rgba = 0
 

Initialize buffer, if it exists, to given color. In case rgba == 0, simply zeroes out memory, since this generally results in black in most pixel formats.

void Image::copyFrom unsigned char *    buffer,
int    width,
int    height,
const PixelFormat   format
 

Copy from a non-Image source. Determine size of buffer in bytes as width x height x depth.

void Image::copyFrom const Image &    that
 

Duplicates another Image. Copy all raster info into private buffer, and copy all other metadata.

void Image::detach  
 

Set the state of this image as if it has no buffer. Releases (but only frees if appropriate) any memory.

unsigned char fl::Image::getAlpha int    x,
int    y
const [inline]
 

void fl::Image::getGray int    x,
int    y,
float &    gray
const [inline]
 

unsigned char fl::Image::getGray int    x,
int    y
const [inline]
 

void fl::Image::getRGBA int    x,
int    y,
float    values[]
const [inline]
 

unsigned int Image::getRGBA int    x,
int    y
const
 

The "RGB" functions are intended for abstract access to the buffer. They perform conversion to whatever the buffer's format is.

unsigned int fl::Image::getYUV int    x,
int    y
const [inline]
 

Image Image::operator * double    factor
 

Creates an image containing this images's pixels scaled by factor. Ie: factor == 1 -> no change; factor == 2 -> bright spots are twice as bright, and dark spots (negative values relative to bias) are twice as dark.

Image & Image::operator *= double    factor
 

Scales each pixel by factor.

Pixel fl::Image::operator() int    x,
int    y
const [inline]
 

Returns a Pixel object that wraps (x,y).

Reimplemented in fl::ImageOf< T >, fl::ImageOf< float >, and fl::ImageOf< unsigned char >.

Image Image::operator+ const Image &    that
 

Creates an image that sums pixel values from this and that.

Image & Image::operator+= double    value
 

Adds value to each pixel.

Image Image::operator- const Image &    that
 

Creates an image whose pixels are the difference between this and that.

Image & fl::Image::operator<<= const Image &    that [inline]
 

Direct assignment by shallow copy. Same semantics as "=". By using a different operator than "=", we allow subclasses to inherit this function.

void Image::read std::istream &    stream
 

void Image::read const std::string &    fileName
 

Read image from fileName. Format will be determined automatically.

void Image::resize int    width,
int    height
 

Changes image to new size. Any pixels that are still visible are aligned correctly. Any newly exposed pixels are set to black.

void fl::Image::setAlpha int    x,
int    y,
unsigned char    alpha
[inline]
 

void fl::Image::setGray int    x,
int    y,
float    gray
[inline]
 

void fl::Image::setGray int    x,
int    y,
unsigned char    gray
[inline]
 

void fl::Image::setRGBA int    x,
int    y,
float    values[]
[inline]
 

void Image::setRGBA int    x,
int    y,
unsigned int    rgba
 

The "rgb" format is always 24-bit RGB, 8 bits per field. Blue is in the least significant byte, then green, then red.

void fl::Image::setYUV int    x,
int    y,
unsigned int    yuv
[inline]
 

void Image::write std::ostream &    stream,
const std::string &    formatName = "pgm"
const
 

void Image::write const std::string &    fileName,
const std::string &    formatName = "pgm"
const
 

Write image to fileName.


Member Data Documentation

Pointer fl::Image::buffer
 

const PixelFormat* fl::Image::format
 

int fl::Image::height
 

See width for interface guarantees.

double fl::Image::timestamp
 

Time when image was captured. If part of a video, then time when image should be displayed.

int fl::Image::width
 

The Image class guarantees that width * height is always non-negative and that the raster stored in buffer has enough allocated memory to contain width * height pixels. (Of course, you can set this field directly, in which case the warranty is void. :).


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 17:13:26 2004 for fl by doxygen1.2.18