TarzaNN
TarzaNN neural network simulator
Public Member Functions | Protected Member Functions | Protected Attributes
Matrix Class Reference

#include <Matrix.h>

Inheritance diagram for Matrix:
Array2D< float > Filter OutputImage AverageFilter DOGFilter DoubleWFilter FileFilter GFilter HistogramFilter IdentityFilter InhibitoryFilter LOGFilter MotionMask RandomFilter RectFilter RetinalFilter WFilter

List of all members.

Public Member Functions

 Matrix (const int nXSize, const int nYSize)
 Matrix (const Matrix &matrix)
Matrixoperator= (const Matrix &matrix)
MatrixcopyData (const Matrix &matrix)
void * getImage ()
void * getImageCopy (uint32_t *x, uint32_t *y, uint32_t *size, void *p)
bool isZero ()
QPoint * getNonZero ()
void setValue (float value)
void setZero ()
void setOne ()
void multiplyScalar (float item)
void addScalar (float item)
void addMatrix (Matrix *input)
bool equals (Matrix *input)
bool equals (Matrix *input, int tol)
void subtractMatrix (Matrix *input)
void dotSquare ()
void punch_out (int window)
void circularMask ()
void clamp (float the_value)
void applyGatingControl (Matrix *theGatingControl)
void applyIOR (Matrix *theIORMap)
void applyThreshold (float the_value)
void applyThresholdBinarize (float the_value)
void applyThresholdAndMark (float value, Matrix *gc)
void setPixels (unsigned char *data)
void setPixels (int *data)
void downsample (Matrix *input)
void downsample_skip (Matrix *input)
void upsample (Matrix *input)
void upsample_skip (Matrix *input, float fill=0)
void resample (Matrix *input, bool skip=false, float fill=0)
float average ()
void setZeroMean ()
void setOneSum ()
void normalize (float scale)
void printContent ()
void printContentMap ()
void save (QDataStream *outStream)
void read (QDataStream *inStream)
void saveActivations (char *filename)
QImage * toSTMQImage (int max=255)
void scaleValues (float minScaleValue, float maxScaleValue)
void dotProduct (Matrix *otherMatrix)
void rectangleCopy (uint32_t r_w, uint32_t r_h, uint32_t x1, uint32_t y1, Matrix *otherMatrix, uint32_t o_x1, uint32_t o_y1)
void shift (int dx, int dy, int fillOption=0)
void rectangleFill (uint32_t x, uint32_t y, uint32_t w, uint32_t h, float theValue)
float sumAll ()
float sumAllPositive ()
float getMaxValue ()
float getMinValue ()
float sumAllAbsolute ()
void addNoise ()
QPoint * getMaxCoords ()
QPoint * getMaxCoordsSpiral ()
int changeBrightnessOp (int value, int brightness)
int changeContrastOp (int value, int contrast)
int changeGammaOp (int value, int gamma)
int changeUsingTable (int value, const int table[])
QImage changeImage (ChangeOp changeOp, const QImage &image, int value)
QImage changeBrightness (const QImage &image, int brightness)
QImage changeContrast (const QImage &image, int contrast)
QImage changeGamma (const QImage &image, int gamma)

Protected Member Functions

void serialize (char *buf)
 Matrix (char *buf)
 Matrix (QString fileName, int fileType)
int getSendSize ()
void createKernel (float *kernel)
 Matrix ()

Protected Attributes

bool created

Detailed Description

Matrix - 2D array of floats. Designed for speed:

The matrix is a 1D array of floats + 1D array of pointers to the beginning of the rows


Constructor & Destructor Documentation

Matrix::Matrix ( char *  buf) [protected]

Constructor from serialized Matrix. Used with void Matrix::serialize(char* buf)

Matrix::Matrix ( QString  fileName,
int  fileType 
) [protected]

Constructor from file. Used by FileFilter.

Matrix::Matrix ( ) [protected]
Matrix::Matrix ( const int  nXSize,
const int  nYSize 
)
Matrix::Matrix ( const Matrix matrix)

Member Function Documentation

void Matrix::addMatrix ( Matrix input)
void Matrix::addNoise ( )
void Matrix::addScalar ( float  item)
void Matrix::applyGatingControl ( Matrix theGatingControl)
void Matrix::applyIOR ( Matrix theIORMap)
void Matrix::applyThreshold ( float  the_value)

Threshold the matrix - all entries below the given value are set to zero

void Matrix::applyThresholdAndMark ( float  value,
Matrix gc 
)

Threshold the matrix and mark winners and losers in gc.

void Matrix::applyThresholdBinarize ( float  the_value)

Threshold the matrix - all entries below the given value are set to zero, above set to 1

float Matrix::average ( )
QImage Matrix::changeBrightness ( const QImage &  image,
int  brightness 
)
int Matrix::changeBrightnessOp ( int  value,
int  brightness 
) [inline]
QImage Matrix::changeContrast ( const QImage &  image,
int  contrast 
)
int Matrix::changeContrastOp ( int  value,
int  contrast 
) [inline]
QImage Matrix::changeGamma ( const QImage &  image,
int  gamma 
)
int Matrix::changeGammaOp ( int  value,
int  gamma 
) [inline]
QImage Matrix::changeImage ( ChangeOp  changeOp,
const QImage &  image,
int  value 
)
int Matrix::changeUsingTable ( int  value,
const int  table[] 
) [inline]
void Matrix::circularMask ( )
void Matrix::clamp ( float  the_value)
Matrix & Matrix::copyData ( const Matrix matrix)
void Matrix::createKernel ( float *  kernel) [protected]

Creates a packed array representation of the Matrix. Used by Filter::getKernel.

void Matrix::dotProduct ( Matrix otherMatrix)

A "flavoured" version of the product. Each element is multiplied with the corresponding one from the other matrix. The otherMatrix is not modified.

void Matrix::dotSquare ( )

Square element by element (used by NonFourier Neurons)

void Matrix::downsample ( Matrix input)

Downsample with averaging

void Matrix::downsample_skip ( Matrix input)

Downsample skipping pixels

bool Matrix::equals ( Matrix input)
bool Matrix::equals ( Matrix input,
int  tol 
)
void * Matrix::getImage ( )

Get the data

void * Matrix::getImageCopy ( uint32_t *  x,
uint32_t *  y,
uint32_t *  size,
void *  p 
)

Get a copy of the data in the buffer provided, or allocate a buffer

Parameters:
xThe width of the image
yThe height of the image
sizeThe seize of the buffer
pThe buffer (function will allocate if NULL)
QPoint * Matrix::getMaxCoords ( )

Coordinates of maximum element (first)

QPoint * Matrix::getMaxCoordsSpiral ( )

Coordinates of maximum element starting in the center and seacrhing in a spiral (max closest to center)

float Matrix::getMaxValue ( ) [inline]

Max element in matrix

float Matrix::getMinValue ( )

Min element in matrix

QPoint * Matrix::getNonZero ( )

Find the coordinates of the first non-zero element in the matrix. Used for STM WTA. Will need to add another function that somehow localizes all the non-zero elements.

int Matrix::getSendSize ( ) [protected]

Size of buffer needed for network communications. For serialize().

Reimplemented in OutputImage.

bool Matrix::isZero ( )
void Matrix::multiplyScalar ( float  item)
void Matrix::normalize ( float  scale)
Matrix & Matrix::operator= ( const Matrix matrix)
void Matrix::printContent ( )
void Matrix::printContentMap ( )
void Matrix::punch_out ( int  window)
void Matrix::read ( QDataStream *  inStream)
void Matrix::rectangleCopy ( uint32_t  r_w,
uint32_t  r_h,
uint32_t  x1,
uint32_t  y1,
Matrix otherMatrix,
uint32_t  o_x1,
uint32_t  o_y1 
)

copies the data from other matrix from a ractangle of size (r_w,r_h) locate at (o_x1,o_y1) into a similar rectangle in the current matrix at (x1,y1).

void Matrix::rectangleFill ( uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h,
float  theValue 
)

fills a rectangle with a specified value

void Matrix::resample ( Matrix input,
bool  skip = false,
float  fill = 0 
)
void Matrix::save ( QDataStream *  outStream)
void Matrix::saveActivations ( char *  filename)
void Matrix::scaleValues ( float  minScaleValue,
float  maxScaleValue 
)

Modifies the values so that they are within this new range.

void Matrix::serialize ( char *  buf) [protected]

Serialize the Matrix into the provided buffer. Called from OutputImage, used with Matrix::Matrix( char* buf)

Reimplemented in OutputImage.

void Matrix::setOne ( ) [inline]
void Matrix::setOneSum ( )
void Matrix::setPixels ( unsigned char *  data)
void Matrix::setPixels ( int *  data)
void Matrix::setValue ( float  value) [inline]
void Matrix::setZero ( ) [inline]
void Matrix::setZeroMean ( )
void Matrix::shift ( int  dx,
int  dy,
int  fillOption = 0 
)

Shifts the content of the matrix by the dx,dy. The rest is filled with 0z for now. if more fill controll needed, further develop the fillOption parameter

fillOption - currently ignored in the current implementation - the empty space gets padded with 0-zz

void Matrix::subtractMatrix ( Matrix input)
float Matrix::sumAll ( ) [inline]

Sum of all matrix elements

float Matrix::sumAllAbsolute ( )
float Matrix::sumAllPositive ( ) [inline]

Sum of all positive matrix elements

QImage * Matrix::toSTMQImage ( int  max = 255)

Creates an QImage out of the matrix.

void Matrix::upsample ( Matrix input)

Upsample duplicating pixels

void Matrix::upsample_skip ( Matrix input,
float  fill = 0 
)

Upsample filling with zero


Member Data Documentation

bool Matrix::created [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines