Public Member Functions | Static Public Member Functions

ImageDataSet Class Reference
[Auxilliary Tools]

Auxilliary Tool: A data structure for maintaining a list of image files and image labels to facilitate training and testing. More...

#include <ImageDataSet.h>

List of all members.

Public Member Functions

 ImageDataSet (int numSlots=0, int labelsPerImage=0)
 Constructor: Create an ImageDataSet with enough memory to hold a certain number of records with a certain number of labels. Note that the resulting data structure is empty -- records have to be added manually.
 ~ImageDataSet ()
 Default Destructor.
ImageDataSetsplit (int splitStart, int splitEnd)
 Split the dataset into two sets: Removes a continuous block of elements from this dataset and adds them to a new one. The total number of elements in both sets is the same as the original number of elements in this set.
ImageDataSetsplit (const std::vector< int > &removeToNewList, int numToRemove)
 Split the dataset into two sets: Removes specified elements from this dataset and adds them to a new one. The total number of elements in both sets is the same as the original number of elements in this set.
void merge (ImageDataSet *setToAdd)
 Combine the elements from another dataset into this dataset. This method is non-destructive, so the second dataset still has all of its elements (i.e. the number of elements across both datasets is not conserved).
std::string getFileName (int fileNumber)
 Access the name of the file located at a certain index.
std::vector< double > getFileLabels (int fileNumber)
 Access the name of the labels located at a certain index.
int numLabelsPerImage ()
 Number of labels describing each image.
int getNumEntries ()
 Number of records currently in the dataset.
void addEntry (const std::string &filename, const std::vector< double > &labels=std::vector< double >(0))
 Programmatically add a single record to the dataset.

Static Public Member Functions

static ImageDataSetloadFromFile (const std::string &imageListFile, const std::string &imageLabelsFile="")
 Create a data set automatically by parsing a file containing list of files and a file containing a list of labels.

Detailed Description

Auxilliary Tool: A data structure for maintaining a list of image files and image labels to facilitate training and testing.

Each ImageDataSet entry consists of a filename and an array of doubles that constitute some information particular to each image. While this class is agnostic to the semantic content of the labels, other classes assume that the 0 and 1 elements of this array contain the (x, y) coordinates of the center of the target object.

An image data set can be constructed programmatically by adding one element at a time, or it can be created from two files. The first file should have a list of file names, one per line. The second file should have the same number of lines, and on each line should be the labels for that image, separated by spaces. All images should have the same number of labels. The data type of each label is assumed to be double.

Author:
Nicholas Butko
Date:
2010 version 0.4

Constructor & Destructor Documentation

ImageDataSet::ImageDataSet ( int  numSlots = 0,
int  labelsPerImage = 0 
)

Constructor: Create an ImageDataSet with enough memory to hold a certain number of records with a certain number of labels. Note that the resulting data structure is empty -- records have to be added manually.

Parameters:
numSlotsSpace is allocated for this many image files.
labelsPerImageSpace is allocated for this many labels per image.
ImageDataSet::~ImageDataSet (  )

Default Destructor.

Deallocates all memory associated with the ImageDataSet.


Member Function Documentation

void ImageDataSet::addEntry ( const std::string &  filename,
const std::vector< double > &  labels = std::vector< double >(0) 
)

Programmatically add a single record to the dataset.

Parameters:
filenameThe location (absolute or relative) of an image file that will be described by labels.
labelsAn array of labels describing the image of length numLabelsPerImage();
vector< double > ImageDataSet::getFileLabels ( int  fileNumber )

Access the name of the labels located at a certain index.

Parameters:
fileNumberIndex of the record to access. Must be between 0 and getNumEntries()-1, inclusive.
Returns:
A pointer to a string containing the array of labels. This array has length numLabelsPerImage().
std::string ImageDataSet::getFileName ( int  fileNumber )

Access the name of the file located at a certain index.

Parameters:
fileNumberIndex of the record to access. Must be between 0 and getNumEntries()-1, inclusive.
Returns:
A pointer to a string containing the file name.
static ImageDataSet* ImageDataSet::loadFromFile ( const std::string &  imageListFile,
const std::string &  imageLabelsFile = "" 
) [static]

Create a data set automatically by parsing a file containing list of files and a file containing a list of labels.

Parameters:
imageListFileA file containing a list of file names, one per line. The files should either be absolute file paths, or should be relative to the directory from which the program is being run.
imageLabelsFileA file containing the same number of lines as imageListFile, and on each line should be the labels for that image, separated by spaces. All images should have the same number of labels. The data type of each label is assumed to be double.
void ImageDataSet::merge ( ImageDataSet setToAdd )

Combine the elements from another dataset into this dataset. This method is non-destructive, so the second dataset still has all of its elements (i.e. the number of elements across both datasets is not conserved).

Parameters:
setToAddAfter merging, all of setToAdd's records will be added to those in the current object
ImageDataSet * ImageDataSet::split ( int  splitStart,
int  splitEnd 
)

Split the dataset into two sets: Removes a continuous block of elements from this dataset and adds them to a new one. The total number of elements in both sets is the same as the original number of elements in this set.

Parameters:
splitStartIndex of the first element to remove, inclusive. After the split, the element previously at this index in in this list will be located at index 0 in the new list.
splitEndIndex of the last element to remove, incluseive. After the split, the element located at the index splitEnd+1 will be located at index splitStart in this list.
ImageDataSet* ImageDataSet::split ( const std::vector< int > &  removeToNewList,
int  numToRemove 
)

Split the dataset into two sets: Removes specified elements from this dataset and adds them to a new one. The total number of elements in both sets is the same as the original number of elements in this set.

Parameters:
removeToNewListAn array of the indexes of elements that you want put into a new list. For example, to remove every-other element, this would be 0, 2, 4, 6, ... After removal, the remaining elements will maintain their same ordering, but the list will be compacted. So in the above example, element 1 will move to index 0, element 3 will move to index 1, element 5 will move to index 2, etc.
numToRemoveThe length of the supplied list.

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