latest version v1.9 - last update 10 Apr 2010 |
Functor to read an image file. More...
#include <ltiALLFunctor.h>
Public Member Functions | |
loadImage () | |
~loadImage () | |
virtual const char * | getTypeName () const |
bool | apply (image &theImage) |
bool | apply (channel8 &theChannel, lti::palette &colors) |
bool | apply (channel &theChannel) |
bool | load (const std::string &filename, image &theImage) |
bool | load (const std::string &filename, channel8 &theChannel, lti::palette &colors) |
bool | load (const std::string &filename, channel &theChannel) |
bool | checkHeader (const std::string &filename, point &imageSize) |
bool | checkHeader (const std::string &filename, point &imageSize, bool &trueColor) |
virtual functor * | clone () const |
Protected Attributes | |
lti::loadBMP | loaderBMP |
lti::loadJPEG | loaderJPEG |
lti::loadPNG | loaderPNG |
lti::splitImageToRGB | rgbSplitter |
lti::splitImageToHSI | hsiSplitter |
Functor to read an image file.
It is NOT thread save, this means, the SAME instance can not be used from different threads or processes at the same time. If this occurs an unpredictible behaviour must be expected!. If you need to read or write many images at the same time, use in each thread an instance of this functor, or protect your code with semaphores.
This class is used to load lti::image or lti::channel objects from files of one of the formats supported by the LTI-Lib.
The load methods will use the extension in the filename to decide the format in which the image should be read.
Three formats are supported: PNG, BMP and JPEG.
Example:
lti::loadImage loader; // functor to load images lti::image img; // the image loaded will be left here. loader.load("myimage.png",img); // load PNG image loader.load("myimage.bmp",img); // load BMP image loader.load("myimage.jpg",img); // load JPG image
The valid extensions are case insensitive matches for .jpg, .jpeg, .png and .bmp.
lti::loadImage::loadImage | ( | ) |
default constructor
lti::loadImage::~loadImage | ( | ) | [inline] |
destructor
bool lti::loadImage::apply | ( | channel & | theChannel | ) |
load channel
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
theChannel | the image on the file will be loaded here |
bool lti::loadImage::apply | ( | channel8 & | theChannel, | |
lti::palette & | colors | |||
) | [virtual] |
load channel
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
theChannel | the image on the file will be loaded here | |
colors | theChannel contains just indexes to the pixel values in this vector. |
Reimplemented from lti::ioFunctor.
bool lti::loadImage::apply | ( | image & | theImage | ) | [virtual] |
load Image
theImage | the file specified in the parameters will be loaded in this image. Note that independently of the soft of image in the file, this will always be converted to a color lti::image. |
Reimplemented from lti::ioFunctor.
bool lti::loadImage::checkHeader | ( | const std::string & | filename, | |
point & | imageSize, | |||
bool & | trueColor | |||
) |
check the data of the image header
filename | name of the image file to be tested | |
imageSize | returns the size of the image: imageSize.x is the number of columns and imageSize.y the number of rows. | |
trueColor | true if the image contains 3x256 bits per pixel, false, otherwise. If false, you can use the methods to read channel8+palette |
bool lti::loadImage::checkHeader | ( | const std::string & | filename, | |
point & | imageSize | |||
) |
virtual functor* lti::loadImage::clone | ( | ) | const [virtual] |
returns a pointer to a clone of the functor.
Implements lti::functor.
virtual const char* lti::loadImage::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("loadImage")
Reimplemented from lti::ioImage.
bool lti::loadImage::load | ( | const std::string & | filename, | |
channel & | theChannel | |||
) |
shortcut for load an image.
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
filename | name of the file to be readed | |
theChannel | variable where the image will be stored |
bool lti::loadImage::load | ( | const std::string & | filename, | |
channel8 & | theChannel, | |||
lti::palette & | colors | |||
) | [virtual] |
shortcut for load an image.
Use this method if you know that the file contains a gray valued image. If you try to load a 24-bit image with this method, some quantization algorithms will be used to reduce the number of colors to 256.
filename | name of the file to be readed | |
theChannel | variable where the image will be stored | |
colors | the palette used will be stored here |
Reimplemented from lti::ioFunctor.
bool lti::loadImage::load | ( | const std::string & | filename, | |
image & | theImage | |||
) | [virtual] |
shortcut for load an image
filename | name of the file to be readed | |
theImage | variable where the image will to be stored |
Reimplemented from lti::ioFunctor.
lti::splitImageToHSI lti::loadImage::hsiSplitter [protected] |
functor to split images to HSI
lti::loadBMP lti::loadImage::loaderBMP [protected] |
functor to load BMP images
lti::loadJPEG lti::loadImage::loaderJPEG [protected] |
functor to load JPEG images
lti::loadPNG lti::loadImage::loaderPNG [protected] |
functor to load PNG images
lti::splitImageToRGB lti::loadImage::rgbSplitter [protected] |
functor to split images to RGB