library of assembled shared sources

http://lass.cocamware.com

lass::io::Image Class Reference

image thing? More...

#include <image.h>

Collaboration diagram for lass::io::Image:

Collaboration graph
[legend]

Data Structures

class  BadFormat
struct  ColorSpace
struct  FileFormat
struct  HeaderIgi
struct  HeaderLass
struct  HeaderPfm
struct  HeaderRadianceHdr
struct  HeaderTarga

Public Types

enum  { numChromaticities = 4 }
typedef prim::ColorRGBA TPixel
typedef std::vector< TPixelTRaster
typedef prim::ColorRGBA::TValue TValue
typedef prim::ColorRGBA::TParam TParam
typedef prim::ColorRGBA::TNumTraits TNumTraits
typedef prim::Point2D
< num::Tfloat32
TChromaticity
typedef TValue(* TFilterFunction )(TValue)

Public Member Functions

 Image ()
 Default constructor.
 Image (unsigned rows, unsigned cols)
 Construct image of given width and height.
 Image (const std::string &filename)
 Construct image from given file.
 Image (const Image &other)
 Copy constructor.
 ~Image ()
 Destructor.
void reset ()
 Reset image to empty image.
void reset (unsigned rows, unsigned cols)
 Reset image to (black) image of given width.
void reset (const std::string &filename)
 Reset image to the one in the given file.
void reset (const Image &other)
 Reset image to copy of given image.
void open (const std::string &filename)
 Open image from file.
void open (BinaryIStream &stream, const std::string &formatTag)
 Open image from binary stream.
void save (const std::string &filename)
 Save image to file.
void save (BinaryOStream &stream, const std::string &formatTag)
 Save image to file.
Imageoperator= (const Image &other)
 Copy other into this image.
void swap (Image &other)
 swap two images
const TPixeloperator[] (unsigned flatIndex) const
TPixeloperator[] (unsigned flatIndex)
const TPixeloperator() (unsigned row, unsigned col) const
 Return const pixel at position row, col.
TPixeloperator() (unsigned row, unsigned col)
 Return reference to pixel at position row, col.
const TPixelat (signed row, signed col) const
 Return const pixel at position row, col.
TPixelat (signed row, signed col)
 Return reference to pixel at position row, col.
const TPixel *const data () const
 Return const data block.
TPixel *const data ()
 Return data block.
const ColorSpacecolorSpace () const
 Return colorSpace of image data.
ColorSpacecolorSpace ()
 Return colorSpace of image data.
void transformColors (const ColorSpace &newColorSpace)
 Transform the colors from the current color spacer to destColorSpace.
const unsigned rows () const
 Return height of image.
const unsigned cols () const
 Return width of image.
const bool isEmpty () const
 Return true if image is empty (no data).
void over (const Image &other)
 this = this over other
void in (const Image &other)
 this = this in other
void out (const Image &other)
 this = this out other
void atop (const Image &other)
 this = this atop other
void through (const Image &other)
 this = this through other
void rover (const Image &other)
 this = other over this
void rin (const Image &other)
 this = other in this
void rout (const Image &other)
 this = other out this
void ratop (const Image &other)
 this = other atop this
void rthrough (const Image &other)
 this = other through this
void plus (const Image &other)
 this = this plus other = other plus this
void clampNegatives ()
 clamp all negative pixel components to zero.
void filterMedian (unsigned boxSize)
 Apply a median filter on image.
void filterGamma (TParam gammaExponent)
 apply gamma correction to image
void filterExposure (TParam exposureTime)
 apply exposure to image
void filterInverseExposure (TParam exposureTime)
 apply exposure to image
void filter (TFilterFunction function)

Private Types

typedef std::map< std::string,
FileFormat
TFileFormats
typedef BinaryIStream &(Image::* TFileOpener )(BinaryIStream &)
typedef BinaryOStream &(Image::* TFileSaver )(BinaryOStream &) const

Private Member Functions

unsigned resize (unsigned rows, unsigned cols)
 (re)allocate data chunck
unsigned flatIndex (unsigned rows, unsigned cols) const
BinaryIStreamopenLass (BinaryIStream &stream)
 Open LASS Raw file.
BinaryIStreamopenTarga (BinaryIStream &stream)
 Open TARGA file.
BinaryIStreamopenTargaTrueColor (BinaryIStream &stream, const HeaderTarga &iHeader)
 Open Type 2 and 11 TARGA file.
BinaryIStreamopenRadianceHdr (BinaryIStream &stream)
BinaryIStreamopenPfm (BinaryIStream &stream)
BinaryIStreamopenIgi (BinaryIStream &stream)
BinaryOStreamsaveLass (BinaryOStream &stream) const
BinaryOStreamsaveTarga (BinaryOStream &stream) const
 Save TARGA file (type 2, 32 bit).
BinaryOStreamsaveRadianceHdr (BinaryOStream &stream) const
 Save RADIANCE HDR.
BinaryOStreamsavePfm (BinaryOStream &stream) const
BinaryOStreamsaveIgi (BinaryOStream &stream) const
FileFormat findFormat (const std::string &formatTag)
std::string readRadianceHdrString (BinaryIStream &stream) const

Static Private Member Functions

static BinaryIStreamreadLine (BinaryIStream &stream, std::string &line)
static BinaryOStreamwriteLine (BinaryOStream &stream, const std::string &line)
static TFileFormats fillFileFormats ()
static const ColorSpace defaultColorSpace ()
 return sRGB as colorSpace
static const ColorSpace xyzColorSpace ()

Private Attributes

ColorSpace colorSpace_
unsigned rows_
unsigned cols_
TRaster raster_

Static Private Attributes

static TFileFormats fileFormats_ = Image::fillFileFormats()
static num::Tuint32 magicLass_ = 0x7373616c
static std::string magicRadiance_ = "#?RADIANCE\n"
static num::Tint32 magicIgi_ = 66613373

Detailed Description

image thing?

Author:
Bram de Greve [BdG]

Definition at line 71 of file image.h.


Member Typedef Documentation

Definition at line 75 of file image.h.

typedef std::vector<TPixel> lass::io::Image::TRaster

Definition at line 76 of file image.h.

Definition at line 78 of file image.h.

Definition at line 79 of file image.h.

Definition at line 80 of file image.h.

Definition at line 84 of file image.h.

typedef std::map<std::string, FileFormat> lass::io::Image::TFileFormats [private]

Definition at line 281 of file image.h.

typedef BinaryIStream&(Image::* lass::io::Image::TFileOpener)(BinaryIStream &) [private]

typedef BinaryOStream&(Image::* lass::io::Image::TFileSaver)(BinaryOStream &) const [private]


Member Enumeration Documentation

anonymous enum

Enumerator:
numChromaticities 

Definition at line 85 of file image.h.


Constructor & Destructor Documentation

lass::io::Image::Image (  ) 

Default constructor.

empty image.

Definition at line 90 of file image.cpp.

lass::io::Image::Image ( unsigned  rows,
unsigned  cols 
)

Construct image of given width and height.

Definition at line 102 of file image.cpp.

References raster_, and resize().

lass::io::Image::Image ( const std::string &  filename  ) 

Construct image from given file.

Definition at line 117 of file image.cpp.

References open().

lass::io::Image::Image ( const Image other  ) 

Copy constructor.

Definition at line 130 of file image.cpp.

lass::io::Image::~Image (  ) 

Destructor.

Definition at line 142 of file image.cpp.


Member Function Documentation

void lass::io::Image::reset (  ) 

Reset image to empty image.

Definition at line 152 of file image.cpp.

References swap().

void lass::io::Image::reset ( unsigned  rows,
unsigned  cols 
)

Reset image to (black) image of given width.

Definition at line 162 of file image.cpp.

References swap().

void lass::io::Image::reset ( const std::string &  filename  ) 

Reset image to the one in the given file.

Definition at line 172 of file image.cpp.

References swap().

void lass::io::Image::reset ( const Image other  ) 

Reset image to copy of given image.

Definition at line 182 of file image.cpp.

References swap().

void lass::io::Image::open ( const std::string &  filename  ) 

Open image from file.

Definition at line 192 of file image.cpp.

References lass::io::fileExtension(), LASS_THROW, LASS_THROW_EX, and lass::util::Exception::message().

Referenced by Image().

void lass::io::Image::open ( BinaryIStream stream,
const std::string &  formatTag 
)

Open image from binary stream.

Definition at line 218 of file image.cpp.

References lass::io::StreamBase::eof(), findFormat(), lass::io::StreamBase::good(), LASS_THROW_EX, lass::io::Image::FileFormat::open, and swap().

void lass::io::Image::save ( const std::string &  filename  ) 

Save image to file.

Definition at line 247 of file image.cpp.

References lass::io::fileExtension(), LASS_THROW, LASS_THROW_EX, and lass::util::Exception::message().

void lass::io::Image::save ( BinaryOStream stream,
const std::string &  formatTag 
)

Image & lass::io::Image::operator= ( const Image other  ) 

Copy other into this image.

Definition at line 297 of file image.cpp.

References swap().

void lass::io::Image::swap ( Image other  ) 

swap two images

Definition at line 308 of file image.cpp.

References colorSpace_, cols_, raster_, and rows_.

Referenced by open(), operator=(), and reset().

const TPixel& lass::io::Image::operator[] ( unsigned  flatIndex  )  const [inline]

Definition at line 135 of file image.h.

TPixel& lass::io::Image::operator[] ( unsigned  flatIndex  )  [inline]

Definition at line 136 of file image.h.

const Image::TPixel & lass::io::Image::operator() ( unsigned  row,
unsigned  col 
) const

Return const pixel at position row, col.

Parameters:
row row of pixel, y coordinate.
col column of pixel, x coordinate.

Definition at line 322 of file image.cpp.

References cols_, flatIndex(), LASS_ASSERT, raster_, and rows_.

Image::TPixel & lass::io::Image::operator() ( unsigned  row,
unsigned  col 
)

Return reference to pixel at position row, col.

Parameters:
row row of pixel, y coordinate.
col column of pixel, x coordinate.

Definition at line 334 of file image.cpp.

References cols_, flatIndex(), LASS_ASSERT, raster_, and rows_.

const Image::TPixel & lass::io::Image::at ( signed  row,
signed  col 
) const

Return const pixel at position row, col.

position is wrapped around.

Parameters:
row row of pixel, y coordinate.
col column of pixel, x coordinate.

Definition at line 346 of file image.cpp.

References cols_, flatIndex(), lass::num::mod(), raster_, and rows_.

Image::TPixel & lass::io::Image::at ( signed  row,
signed  col 
)

Return reference to pixel at position row, col.

position is wrapped around.

Parameters:
row row of pixel, y coordinate.
col column of pixel, x coordinate.

Definition at line 359 of file image.cpp.

References cols_, flatIndex(), lass::num::mod(), raster_, and rows_.

const Image::TPixel *const lass::io::Image::data (  )  const

Return const data block.

Definition at line 370 of file image.cpp.

References raster_.

Image::TPixel *const lass::io::Image::data (  ) 

Return data block.

Definition at line 379 of file image.cpp.

References raster_.

const Image::ColorSpace & lass::io::Image::colorSpace (  )  const

Return colorSpace of image data.

Definition at line 388 of file image.cpp.

References colorSpace_.

Referenced by transformColors().

Image::ColorSpace & lass::io::Image::colorSpace (  ) 

Return colorSpace of image data.

You can change the parameters of the current color space without transforming the pixels. This is most useful if you know that the pixels are in a different color space that the current one is set to. For example, if you know the pixels have a gamma correction 2.2 applied, but the this->colorSpace().gamma == 1.

Definition at line 402 of file image.cpp.

References colorSpace_.

void lass::io::Image::transformColors ( const ColorSpace newColorSpace  ) 

Transform the colors from the current color spacer to destColorSpace.

The transformation consists of three stages:

  • linearise pixels if gamma of current color space != 1
  • transform colors to linearised destination colour space
  • apply gamma correction if destColorSpace.gamma != 1
For the color transformation, two transformations are concatenated. Both of them will also perform a chromatic adaption transform if the white point of either color space is not the equal energy one (E):
  • from source RGB to XYZ
  • from XYZ to dest RGB

Definition at line 422 of file image.cpp.

References lass::io::Image::ColorSpace::blue, lass::stde::C, colorSpace(), colorSpace_, lass::prim::concatenate(), filterGamma(), lass::io::Image::ColorSpace::gamma, lass::io::Image::ColorSpace::green, lass::io::Image::ColorSpace::isFromFile, raster_, lass::io::Image::ColorSpace::red, lass::prim::transform(), lass::io::Image::ColorSpace::white, lass::prim::Point2D< T >::x, and lass::prim::Point2D< T >::y.

const unsigned lass::io::Image::rows (  )  const

Return height of image.

Definition at line 484 of file image.cpp.

References rows_.

const unsigned lass::io::Image::cols (  )  const

Return width of image.

Definition at line 493 of file image.cpp.

References cols_.

const bool lass::io::Image::isEmpty (  )  const

Return true if image is empty (no data).

Definition at line 502 of file image.cpp.

References raster_.

void lass::io::Image::over ( const Image other  ) 

this = this over other

Definition at line 511 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, lass::prim::over(), raster_, and lass::prim::transform().

void lass::io::Image::in ( const Image other  ) 

this = this in other

Definition at line 521 of file image.cpp.

References lass::prim::in(), LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, and lass::prim::transform().

void lass::io::Image::out ( const Image other  ) 

this = this out other

Definition at line 531 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, lass::prim::out(), raster_, and lass::prim::transform().

void lass::io::Image::atop ( const Image other  ) 

this = this atop other

Definition at line 541 of file image.cpp.

References lass::prim::atop(), LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, and lass::prim::transform().

void lass::io::Image::through ( const Image other  ) 

this = this through other

Definition at line 551 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, lass::prim::through(), and lass::prim::transform().

void lass::io::Image::rover ( const Image other  ) 

this = other over this

Definition at line 561 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, lass::prim::over(), raster_, and lass::prim::transform().

void lass::io::Image::rin ( const Image other  ) 

this = other in this

Definition at line 571 of file image.cpp.

References lass::prim::in(), LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, and lass::prim::transform().

void lass::io::Image::rout ( const Image other  ) 

this = other out this

Definition at line 581 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, lass::prim::out(), raster_, and lass::prim::transform().

void lass::io::Image::ratop ( const Image other  ) 

this = other atop this

Definition at line 591 of file image.cpp.

References lass::prim::atop(), LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, and lass::prim::transform().

void lass::io::Image::rthrough ( const Image other  ) 

this = other through this

Definition at line 601 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, raster_, lass::prim::through(), and lass::prim::transform().

void lass::io::Image::plus ( const Image other  ) 

this = this plus other = other plus this

Definition at line 611 of file image.cpp.

References LASS_IO_IMAGE_ENFORCE_SAME_SIZE, lass::prim::plus(), raster_, and lass::prim::transform().

void lass::io::Image::clampNegatives (  ) 

clamp all negative pixel components to zero.

Definition at line 621 of file image.cpp.

References raster_.

void lass::io::Image::filterMedian ( unsigned  boxSize  ) 

Apply a median filter on image.

Parameters:
boxSize size of box filter, must be odd.
  • Filters only pixels with alphachannel != 0.
  • We use the vector median filter for colour images, as described on page in GAUCH J. M. (1998). Noise Removal and contrast enhancement. In: Sangwine S. J. & Horne R. E. N. (Eds.) The Colour Image Processing Handbook. London, Chapman & Hall, 149-162.

Definition at line 644 of file image.cpp.

References lass::prim::ColorRGBA::a, cols_, lass::prim::distance(), LASS_ASSERT, LASS_THROW, raster_, rows_, and lass::num::NumTraits< C >::zero.

void lass::io::Image::filterGamma ( TParam  gammaExponent  ) 

apply gamma correction to image

Definition at line 730 of file image.cpp.

References colorSpace_, lass::io::Image::ColorSpace::gamma, and raster_.

Referenced by transformColors().

void lass::io::Image::filterExposure ( TParam  exposureTime  ) 

apply exposure to image

Definition at line 744 of file image.cpp.

References raster_.

void lass::io::Image::filterInverseExposure ( TParam  exposureTime  ) 

apply exposure to image

Definition at line 757 of file image.cpp.

References raster_.

void lass::io::Image::filter ( TFilterFunction  function  ) 

unsigned lass::io::Image::resize ( unsigned  rows,
unsigned  cols 
) [private]

(re)allocate data chunck

Definition at line 777 of file image.cpp.

References cols_, raster_, and rows_.

Referenced by Image(), openIgi(), openLass(), openPfm(), openRadianceHdr(), and openTarga().

unsigned lass::io::Image::flatIndex ( unsigned  rows,
unsigned  cols 
) const [inline, private]

Definition at line 284 of file image.h.

Referenced by at(), and operator()().

BinaryIStream & lass::io::Image::openLass ( BinaryIStream stream  )  [private]

BinaryIStream & lass::io::Image::openTarga ( BinaryIStream stream  )  [private]

BinaryIStream & lass::io::Image::openTargaTrueColor ( BinaryIStream stream,
const HeaderTarga iHeader 
) [private]

BinaryIStream & lass::io::Image::openRadianceHdr ( BinaryIStream stream  )  [private]

BinaryIStream & lass::io::Image::openPfm ( BinaryIStream stream  )  [private]

BinaryIStream & lass::io::Image::openIgi ( BinaryIStream stream  )  [private]

BinaryOStream & lass::io::Image::saveLass ( BinaryOStream stream  )  const [private]

BinaryOStream & lass::io::Image::saveTarga ( BinaryOStream stream  )  const [private]

BinaryOStream & lass::io::Image::saveRadianceHdr ( BinaryOStream stream  )  const [private]

BinaryOStream & lass::io::Image::savePfm ( BinaryOStream stream  )  const [private]

BinaryOStream & lass::io::Image::saveIgi ( BinaryOStream stream  )  const [private]

Image::FileFormat lass::io::Image::findFormat ( const std::string &  formatTag  )  [private]

Definition at line 1481 of file image.cpp.

References fileFormats_, LASS_THROW_EX, and lass::stde::tolower().

Referenced by open(), and save().

std::string lass::io::Image::readRadianceHdrString ( BinaryIStream stream  )  const [private]

BinaryIStream & lass::io::Image::readLine ( BinaryIStream stream,
std::string &  line 
) [static, private]

BinaryOStream & lass::io::Image::writeLine ( BinaryOStream stream,
const std::string &  line 
) [static, private]

Image::TFileFormats lass::io::Image::fillFileFormats (  )  [static, private]

const Image::ColorSpace lass::io::Image::defaultColorSpace (  )  [static, private]

const Image::ColorSpace lass::io::Image::xyzColorSpace (  )  [static, private]


Field Documentation

unsigned lass::io::Image::rows_ [private]

unsigned lass::io::Image::cols_ [private]

Image::TFileFormats lass::io::Image::fileFormats_ = Image::fillFileFormats() [static, private]

Definition at line 318 of file image.h.

Referenced by findFormat().

num::Tuint32 lass::io::Image::magicLass_ = 0x7373616c [static, private]

Definition at line 319 of file image.h.

Referenced by openLass(), and saveLass().

std::string lass::io::Image::magicRadiance_ = "#?RADIANCE\n" [static, private]

num::Tint32 lass::io::Image::magicIgi_ = 66613373 [static, private]

Definition at line 321 of file image.h.

Referenced by openIgi(), and saveIgi().


The documentation for this class was generated from the following files:

Generated on Mon Nov 10 14:22:09 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo