refinery
RAW file processor
Public Types | Public Member Functions

refinery::Image< T > Class Template Reference

A grid of pixels with accompanying metadata. More...

#include <refinery/image.h>

Collaboration diagram for refinery::Image< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T PixelType
 Type of each pixel.
typedef T::ValueType ValueType
 Color value type.
typedef T::ColorType ColorType
 Color index type.

Public Member Functions

 Image (const CameraData &cameraData, int width, int height)
 Constructor.
const CameraDatacameraData () const
 The photograph CameraData.
unsigned int width () const
 Image width in pixels.
unsigned int height () const
 Image height in pixels.
unsigned int nPixels () const
 Number of pixels in the Image.
unsigned int filters () const
 Filters (cached from cameraData()) FIXME remove this.
void setFilters (unsigned int filters)
 Filters (cached from cameraData()) FIXME remove this.
ColorType colorAtPoint (const Point &point) const
 The color of the camera sensor array at this point.
ColorType colorAtPoint (unsigned int row, unsigned int col) const
 The color of the camera sensor array at this point.
PixelTypepixels ()
 A pointer to the first pixel in the image, useful for iterating.
PixelTypepixelsEnd ()
 A pointer to one past the last pixel in the image, useful for iterating.
const PixelTypeconstPixels () const
 A pointer to the first pixel in the image, useful for iterating.
const PixelTypeconstPixelsEnd () const
 A pointer to one past the last pixel in the image, useful for iterating.
const PixelTypeconstPixelsAtRow (int row) const
 A pointer to the first pixel in the given row, useful for iterating.
PixelTypepixelsAtRow (int row)
 A pointer to the first pixel in the given row, useful for iterating.
PixelTypepixelsAtPoint (const Point &point)
 A pointer to the specified pixel, useful for iterating.
PixelTypepixelsAtPoint (unsigned int row, unsigned int col)
 A pointer to the specified pixel, useful for iterating.
const PixelTypeconstPixelsAtPoint (const Point &point) const
 A pointer to the specified pixel, useful for iterating.
const PixelTypeconstPixelsAtPoint (unsigned int row, unsigned int col) const
 A pointer to the specified pixel, useful for iterating.
PixelTypepixelAtPoint (const Point &point)
 A mutable pixel at the specified point.
PixelTypepixelAtPoint (unsigned int row, unsigned int col)
 A mutable pixel at the specified point.
const PixelTypeconstPixelAtPoint (const Point &point) const
 An immutable pixel at the specified point.
const PixelTypeconstPixelAtPoint (unsigned int row, unsigned int col) const
 An immutable pixel at the specified point.

Detailed Description

template<typename T>
class refinery::Image< T >

A grid of pixels with accompanying metadata.

The image pixels are contiguous and can be accessed as one big array using pixels().

Template Parameters:
TThe type of Pixel in the grid (use a Pixel).
Examples:

util/raw2ppm.cc.

Definition at line 332 of file image.h.


Member Typedef Documentation

template<typename T >
typedef T::ColorType refinery::Image< T >::ColorType

Color index type.

Definition at line 336 of file image.h.

template<typename T >
typedef T refinery::Image< T >::PixelType

Type of each pixel.

Definition at line 334 of file image.h.

template<typename T >
typedef T::ValueType refinery::Image< T >::ValueType

Color value type.

Definition at line 335 of file image.h.


Constructor & Destructor Documentation

template<typename T >
refinery::Image< T >::Image ( const CameraData cameraData,
int  width,
int  height 
) [inline]

Constructor.

This allocates the space needed to store all the Pixels and sets them to default values of 0.

Parameters:
[in]cameraDataCameraData that applies to the photograph.
[in]widthImage width in pixels.
[in]heightImage height in pixels.

Definition at line 362 of file image.h.


Member Function Documentation

template<typename T >
ColorType refinery::Image< T >::colorAtPoint ( unsigned int  row,
unsigned int  col 
) const [inline]

The color of the camera sensor array at this point.

Even in a fully-interpolated RGB image, it's sometimes useful to know which color value is exact and which are interpolated. This method will tell that for any type Image.

Parameters:
[in]rowPixel row (from the top).
[in]colPixel column (from the left).
Returns:
Color in the sensor array, as reported by the camera.

Definition at line 422 of file image.h.

template<typename T >
ColorType refinery::Image< T >::colorAtPoint ( const Point point) const [inline]

The color of the camera sensor array at this point.

Even in a fully-interpolated RGB image, it's sometimes useful to know which color value is exact and which are interpolated. This method will tell that for any type Image.

Parameters:
[in]pointPoint in question.
Returns:
Color in the sensor array, as reported by the camera.

Definition at line 406 of file image.h.

template<typename T >
const PixelType* refinery::Image< T >::constPixelsAtPoint ( const Point point) const [inline]

A pointer to the specified pixel, useful for iterating.

Parameters:
[in]pointPoint of the pixel.
Returns:
A pixel pointer.

Definition at line 507 of file image.h.

template<typename T >
const PixelType* refinery::Image< T >::constPixelsAtPoint ( unsigned int  row,
unsigned int  col 
) const [inline]

A pointer to the specified pixel, useful for iterating.

Parameters:
[in]rowPixel row (from the top).
[in]colPixel column (from the left).
Returns:
A pixel pointer.

Definition at line 519 of file image.h.

template<typename T >
const PixelType* refinery::Image< T >::constPixelsAtRow ( int  row) const [inline]

A pointer to the first pixel in the given row, useful for iterating.

Parameters:
[in]rowPixel row (from the top).
Returns:
A pixel pointer.

Definition at line 467 of file image.h.

template<typename T >
PixelType* refinery::Image< T >::pixels ( ) [inline]

A pointer to the first pixel in the image, useful for iterating.

Example: convert an RGB image to BGR

 typedef Image<Pixel<unsigned char, 3> > ImageType;
 CameraData cameraData = findCameraDataSomehow();
 ImageType image(cameraData, 100, 100);
 // fill in image...
 for (ImageType::PixelType* p = image.pixels(), p < image.pixelsEnd(); p++)
 {
   ImageType::PixelType& pixel(*p);
   ImageType::ValueType temp(pixel[0]);
   pixel[0] = pixel[2];
   pixel[2] = temp;
 }
Returns:
A pixel pointer.

Definition at line 446 of file image.h.

template<typename T >
PixelType* refinery::Image< T >::pixelsAtPoint ( unsigned int  row,
unsigned int  col 
) [inline]

A pointer to the specified pixel, useful for iterating.

Parameters:
[in]rowPixel row (from the top).
[in]colPixel column (from the left).
Returns:
A pixel pointer.

Definition at line 498 of file image.h.

template<typename T >
PixelType* refinery::Image< T >::pixelsAtPoint ( const Point point) [inline]

A pointer to the specified pixel, useful for iterating.

Parameters:
[in]pointPoint of the pixel.
Returns:
A pixel pointer.

Definition at line 486 of file image.h.

template<typename T >
PixelType* refinery::Image< T >::pixelsAtRow ( int  row) [inline]

A pointer to the first pixel in the given row, useful for iterating.

Parameters:
[in]rowPixel row (from the top).
Returns:
A pixel pointer.

Definition at line 476 of file image.h.

template<typename T >
void refinery::Image< T >::setFilters ( unsigned int  filters) [inline]

Filters (cached from cameraData()) FIXME remove this.

Parameters:
[in]filtersNew filters to set.

Definition at line 394 of file image.h.


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