LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::loadImageList Class Reference

This functor loads images given either in a std::list of strings, a special file or a whole directory: Each apply call loads the next image from the list. More...

#include <ltiLoadImageList.h>

Inheritance diagram for lti::loadImageList:
Inheritance graph
[legend]
Collaboration diagram for lti::loadImageList:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class loadImageList More...

Public Member Functions

 loadImageList ()
 loadImageList (const parameters &par)
 loadImageList (const loadImageList &other)
 loadImageList (const std::string &name, parameters::eOperationMode mode=parameters::ListFileName)
 loadImageList (const std::list< std::string > &names)
virtual ~loadImageList ()
virtual const char * getTypeName () const
loadImageListcopy (const loadImageList &other)
loadImageListoperator= (const loadImageList &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool updateParameters ()
bool hasNext () const
const std::string & getNextFileName () const
void rewind ()
int size () const
bool use (const std::string &name, parameters::eOperationMode mode=parameters::ListFileName)
bool use (const std::list< std::string > &names)
bool apply (image &theImage)
bool apply (channel8 &theChannel, lti::palette &colors)
bool apply (channel &theChannel)
bool apply (std::vector< image > &theImages)
bool apply (std::vector< channel8 > &theChannels, std::vector< lti::palette > &colors)
bool apply (std::vector< channel > &theChannels)
bool checkHeader (point &imageSize)
bool checkHeader (point &imageSize, bool &trueColor)

Protected Member Functions

bool getImageNames ()
bool readListFile (const std::string &filename)
bool readDirectory (const std::string &dirName)
bool hasImageExtension (std::string &filename)

Protected Attributes

std::list< std::string > fileNames
std::list< std::string >
::const_iterator 
iter
const std::string emptyDummy
loadImage iLoader

Detailed Description

This functor loads images given either in a std::list of strings, a special file or a whole directory: Each apply call loads the next image from the list.

The source of the list of image filenames can be chosen via the parameters parameters::mode. All images which are of types PNG, BMP or JPEG are loaded. The default is a textfile with a list of filenames: parameters::listFileName contains the name of the file (must be set) and parameters::mode is parameters::ListFileName. Note: see parameters::mode for corresponding parameter.

Setting the parameter parameters::skipErrors to true makes the functor error tolerant. I.e. if an image in the list can not be loaded, false is returned and the image name is in the status string. However, the next valid image in the list is returned. If the parameter is false, false is returned and no image is loaded. Default is true.


Constructor & Destructor Documentation

lti::loadImageList::loadImageList (  ) 

default constructor

lti::loadImageList::loadImageList ( const parameters par  ) 

Construct a functor using the given parameters.

lti::loadImageList::loadImageList ( const loadImageList other  ) 

copy constructor

Parameters:
other the object to be copied
lti::loadImageList::loadImageList ( const std::string &  name,
parameters::eOperationMode  mode = parameters::ListFileName 
)

Sets one of two modes: parameters::ListFileName or parameters::DirName and the corresponding name of the file or directory in the parameters.

Default is the filename of a textfile containing image filenames.

See also loadImageList(const std::list<std::string>&), use(const std::string&, parameters::eOperationMode), use(const std::list<std::string>&).

Parameters:
name name of a file containing image filenames or of a directory
mode parameters::ListFileName or parameters::DirName.
lti::loadImageList::loadImageList ( const std::list< std::string > &  names  ) 
virtual lti::loadImageList::~loadImageList (  )  [virtual]

destructor


Member Function Documentation

bool lti::loadImageList::apply ( std::vector< channel > &  theChannels  ) 

load all images from the list given in the parameters, via the constructor or by calling use().

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, the intensity channel is extracted.

Parameters:
theChannels all images specified in the parameters
Returns:
true if successful, false otherwise.
bool lti::loadImageList::apply ( std::vector< channel8 > &  theChannels,
std::vector< lti::palette > &  colors 
)

load all images from the list given in the parameters, via the constructor or by calling use().

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.

Parameters:
theChannels all images specified in the parameters
colors theChannels contains just indexes to the pixel values in this vector.
Returns:
false on error
bool lti::loadImageList::apply ( std::vector< image > &  theImages  ) 

load all images from the list given in the parameters, via the constructor or by calling use().

Parameters:
theImages all files specified in the parameters will be loaded. Note that independently of the kind of images in the files, they are always converted to a color lti::image.
Returns:
false on error
bool lti::loadImageList::apply ( channel theChannel  ) 

load the next image from the list given in the parameters, via the constructor or by calling use().

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, the intensity channel is extracted.

Parameters:
theChannel the image on the file will be loaded here
Returns:
true if successful, false otherwise.
bool lti::loadImageList::apply ( channel8 theChannel,
lti::palette colors 
) [virtual]

load the next image from the list given in the parameters, via the constructor or by calling use().

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.

Parameters:
theChannel the image on the file will be loaded here
colors theChannel contains just indexes to the pixel values in this vector.
Returns:
true if successful, false otherwise.

Reimplemented from lti::ioFunctor.

bool lti::loadImageList::apply ( image theImage  )  [virtual]

load the next image from the list given in the parameters, via the constructor or by calling use().

Parameters:
theImage the file specified in the parameters will be loaded in this image. Note that independently of the sort of image in the file, this will always be converted to a color lti::image.
Returns:
false on error

Reimplemented from lti::ioFunctor.

bool lti::loadImageList::checkHeader ( point imageSize,
bool &  trueColor 
)

check the header data of the next image and retrieve the size if the filename specifies a valid image file.

Parameters:
imageSize returns the size of the image: imageSize.x is the number of columns and imageSize.y the numbeer 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
Returns:
true if file is ok, false otherwise
bool lti::loadImageList::checkHeader ( point imageSize  ) 

check the header data of the next image and retrieve the size if the filename specifies a valid image file.

Parameters:
imageSize returns the size of the image: imageSize.x is the number of columns and imageSize.y the number of rows.
Returns:
true if file is ok, false otherwise
virtual functor* lti::loadImageList::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::functor.

Reimplemented in lti::loadVectorImageList.

loadImageList& lti::loadImageList::copy ( const loadImageList other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

Reimplemented in lti::loadVectorImageList.

bool lti::loadImageList::getImageNames (  )  [protected]

Analyses the parameters and loads the filenames for the images from the appropriate source.

If anything goes wrong, the statusString is set and false is returned.

const std::string& lti::loadImageList::getNextFileName (  )  const

Returns the filename of the image which will be loaded by the next call to an apply method.

const parameters& lti::loadImageList::getParameters (  )  const

returns used parameters

Reimplemented from lti::ioFunctor.

Reimplemented in lti::loadVectorImageList.

virtual const char* lti::loadImageList::getTypeName (  )  const [virtual]

returns the name of this type ("loadImageList")

Reimplemented from lti::ioFunctor.

Reimplemented in lti::loadVectorImageList.

bool lti::loadImageList::hasImageExtension ( std::string &  filename  )  [protected]

return true if the filename has an image extension

bool lti::loadImageList::hasNext (  )  const

Returns true if more images are available for loading.

loadImageList& lti::loadImageList::operator= ( const loadImageList other  ) 

alias for copy member

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

Reimplemented in lti::loadVectorImageList.

bool lti::loadImageList::readDirectory ( const std::string &  dirName  )  [protected]

Selects all image filenames in the given directory for reading.

Returns false if the directory does not exist.

bool lti::loadImageList::readListFile ( const std::string &  filename  )  [protected]

Reads the textfile filename which contains filenames of images.

Returns false if the file could not be opened.

void lti::loadImageList::rewind (  ) 

Starts over from the beginning of the list of image filenames.

However, the information is not reread from the parameters. This only happens when setParameters(), use() or a constructor are called.

int lti::loadImageList::size (  )  const

Returns the number of image filenames the functor knows.

Note that this is not necessarily the number of images that will be loaded, since loading might fail for some images.

virtual bool lti::loadImageList::updateParameters (  )  [virtual]

Set the parameters and loads the list of filenames given in the parameters into the functor.

Returns false if cloning of parameters failed or the source of the image files could not be found. The functor is reset by setting new parameters.

Reimplemented from lti::functor.

Reimplemented in lti::loadVectorImageList.

bool lti::loadImageList::use ( const std::list< std::string > &  names  ) 

Sets parameters::mode to parameters::NameList and uses the list names for loading the files.

If false is returned an error occured.

See also loadImageList(const std::list<std::string>&), loadImageList(const std::string&, parameters::eOperationMode), use(const std::string&, parameters::eOperationMode)

Parameters:
names list of image filenames.
Returns:
false on error
bool lti::loadImageList::use ( const std::string &  name,
parameters::eOperationMode  mode = parameters::ListFileName 
)

Sets one of two modes: parameters::ListFileName or parameters::DirName and the corresponding name of the file or directory in the parameters.

Default is the filename of a textfile containing image filenames. If false is returned, there was an error loading the given file.

See also loadImageList(const std::list<std::string>&), loadImageList(const std::string&, parameters::eOperationMode), use(const std::list<std::string>&).

Parameters:
name name of a file containing image filenames or of a directory
mode parameters::ListFileName or parameters::DirName.
Returns:
false on error

Member Data Documentation

const std::string lti::loadImageList::emptyDummy [protected]

empty dummy string

std::list<std::string> lti::loadImageList::fileNames [protected]

internal list of filenames to be loaded

functor used for loading images

std::list<std::string>::const_iterator lti::loadImageList::iter [protected]

iterator for fileNames


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

Generated on Sat Apr 10 15:28:04 2010 for LTI-Lib by Doxygen 1.6.1