QVGenericImage Class Reference

Base class for QVImage objects. More...

#include <qvcore/qvimage.h>

Inherited by QVImage< Type, Channels >.

List of all members.

Public Member Functions

 QVGenericImage ()
 Default constructor.
 QVGenericImage (QVGenericImage const &img)
 Copy constructor.
virtual ~QVGenericImage ()
virtual uInt getCols () const =0
 Virtual method for getting number of columns from image.
virtual uInt getRows () const =0
 Virtual method for getting number of rows from image.
virtual uInt getStep () const =0
 Virtual method for getting step from image.
virtual uInt getChannels () const =0
 Virtual method for getting number of planes for the image.
virtual uInt getTypeSize () const =0
 Virtual method for getting bit depth of the image, in bytes.
virtual uInt getDataSize () const =0
 Virtual method for getting data size for the image.
const QRect & getROI () const
 Method for obtaining actual region of interest for image.
const QPoint & getAnchor () const
 Obtains actual anchor for image.
void resetROI ()
 Resets the region of interest of the image.
void erodeROI (uInt cols, uInt rows)
 Reduces the region of interest of the image, in a given amount of pixels.
void dilateROI (uInt cols, uInt rows)
 Increments the region of interest of the image, in a given amount of pixels.
void setROI (int x, int y, uInt w, uInt h)
 Sets dimensions and location of region of interest in an image.
void setMarginROI (int margin)
 Sets the region of interest for an image, holding the whole image, except a border of a given width.
void setROI (const QRect &rect)
 Directly sets the region of interest for an image, with a given rectangle.
void resetAnchor ()
 Sets anchor to pixel (0,0).
void setAnchor (int col, int row)
 Sets anchor to a given pixel coordinates.
void setAnchor (const QPoint &point)
 Directly sets anchor to a given pixel coordinates, given a point.
virtual const char * getTypeQString () const =0
 Function to make introspection in the image, and obtain a char string identifying the type of the real image contained in the QVGenericImage.
bool isCompatibleWith (const char *qvImageClassName) const
 Function to check whether an image is compatible with given image type id char string.
bool isCompatibleWith (const QVGenericImage *image) const
 Function to check whether an image is compatible with this image.

Protected Attributes

QRect roi
QPoint anchor


Detailed Description

Base class for QVImage objects.

For instance, this class is usefull to create code like this:

int imageAreaSize(QVGenericImage *image)
        {
        return image->getCols() * image->getRows();
        }

Where it doesn't matter the bit depth or number of channels of the image, but the number of cols and rows of it, as well as generic containers, that can hold a variety of image types, for example:

class GenericImageContainer
        {
        public:
                int count;
                QVGenericImage *images;
                [...]
                void addImage(QVGenericImage *image)    { images[count++] = &image; }
                QVGenericImage getImage(int index)      { return images[index]; }
        }

Thus, this class offers access methods for all kind of information about the image, like dimensions (see getCols() and getRows() methods), bit depth and number of planes (see getTypeSize() and getChannels() methods), ROI and anchor of the image (see getROI() and getAnchor() methods mainly), but pixel accessor methods, that are defined in the subclass QVImage, and depends on the bit depth and number of planes of the image.

See also:
QVImage

Definition at line 121 of file qvimage.h.


Constructor & Destructor Documentation

QVGenericImage::QVGenericImage (  )  [inline]

Default constructor.

Initializes image ROI and anchor to zero offset and width, both.

Definition at line 127 of file qvimage.h.

QVGenericImage::QVGenericImage ( QVGenericImage const &  img  )  [inline]

Copy constructor.

Initializes image ROI and anchor to ROI and anchor from image 'img'.

Definition at line 132 of file qvimage.h.

virtual QVGenericImage::~QVGenericImage (  )  [inline, virtual]

Virtual destructor for QVGenericImage.

Definition at line 135 of file qvimage.h.


Member Function Documentation

virtual uInt QVGenericImage::getCols (  )  const [pure virtual]

Virtual method for getting number of columns from image.

Returns:
number of columns for image,

Implemented in QVImage< Type, Channels >.

Referenced by resetROI(), setAnchor(), setMarginROI(), and setROI().

virtual uInt QVGenericImage::getRows (  )  const [pure virtual]

Virtual method for getting number of rows from image.

Returns:
number of rows for image,

Implemented in QVImage< Type, Channels >.

Referenced by resetROI(), setAnchor(), setMarginROI(), and setROI().

virtual uInt QVGenericImage::getStep (  )  const [pure virtual]

Virtual method for getting step from image.

This functions returns the distance in bytes between starts of consecutive lines in the image.

This may be not equal to a multiple of the number of columns, so this value is necessary to normal access to the image.

Returns:
distance in bytes between two consecutive lines in the image.

Implemented in QVImage< Type, Channels >.

virtual uInt QVGenericImage::getChannels (  )  const [pure virtual]

Virtual method for getting number of planes for the image.

Returned value should be equal to template parameter 'Channels', for any QVImage. This is the number of channels that can be accessed in the image.

Returns:
number of channels of the image.

Implemented in QVImage< Type, Channels >.

virtual uInt QVGenericImage::getTypeSize (  )  const [pure virtual]

Virtual method for getting bit depth of the image, in bytes.

Returned value should be equal to size of template parameter 'Type', for any QVImage. This is the size of any element of the data array that stores the image in memory.

Returns:
number of channels of the image.

Implemented in QVImage< Type, Channels >.

virtual uInt QVGenericImage::getDataSize (  )  const [pure virtual]

Virtual method for getting data size for the image.

This functions, for any image, returns the following value:

dataSize = rows * step * planes 

Returns:
size in bytes of data buffer for the image.

Implemented in QVImage< Type, Channels >.

const QRect& QVGenericImage::getROI (  )  const [inline]

Method for obtaining actual region of interest for image.

The region of interest of an image is used for various operations over it. Check the manual for further documentation

Returns:
a QRect that contains the region of interest of the image.

Definition at line 187 of file qvimage.h.

References roi.

Referenced by qvipp::Canny(), dilateROI(), qvdta::draw(), erodeROI(), qvipp::FastMarching(), qvipp::Inpaint(), qvipp::MinEigenVal(), and QVImage< Type, Channels >::operator==().

const QPoint& QVGenericImage::getAnchor (  )  const [inline]

Obtains actual anchor for image.

The anchor of an image is used for various operations over it. Check the manual for further documentation

Returns:
a QPoint that indicates anchor of the image.

Definition at line 195 of file qvimage.h.

References anchor.

Referenced by qvipp::Canny(), qvipp::FastMarching(), qvipp::Inpaint(), and qvipp::MinEigenVal().

void QVGenericImage::resetROI (  )  [inline]

Resets the region of interest of the image.

Makes the region of interest of the image hold the whole image.

That is, makes the region of interest be the rectangle which has upper left corner in pixel (0,0), and lower right corner in pixel (columns, rows), where columns and rows are the number of columns and rows of the image.

Definition at line 206 of file qvimage.h.

References getCols(), getRows(), and setROI().

void QVGenericImage::erodeROI ( uInt  cols,
uInt  rows 
) [inline]

Reduces the region of interest of the image, in a given amount of pixels.

Adds cols and rows parameters to the top left corner of the region of interest, and those values doubled, to the width.

That is, reduces the region of interest in a border, of columns and rows indicated in the parameters.

Parameters:
cols columns which should be reduced from the border of the roi.
rows rows which should be reduced from the border of the roi.

Definition at line 217 of file qvimage.h.

References getROI(), and setROI().

void QVGenericImage::dilateROI ( uInt  cols,
uInt  rows 
) [inline]

Increments the region of interest of the image, in a given amount of pixels.

Substracts cols and rows parameters to the top left corner of the region of interest, and those values doubled, to the width.

That is, increments the region of interest in a border, of columns and rows indicated in the parameters.

Parameters:
cols columns which should be incremented to the border of the roi.
rows rows which should be incremented to the border of the roi.

Definition at line 229 of file qvimage.h.

References getROI(), and setROI().

void QVGenericImage::setROI ( int  x,
int  y,
uInt  w,
uInt  h 
) [inline]

Sets dimensions and location of region of interest in an image.

Region of interest for an image is a rectangle significant to many operations that can be done over an image.

It is defined by pixel where top left corner for this rectangle is located, and width & height of this rectangle.

Parameters:
x column for the pixel where top left corner of the region of interest is located.
y row for the pixel where top left corner of the region of interest is located.
w width for the region of interest.
h height for the region of interest.

Definition at line 244 of file qvimage.h.

Referenced by qvipp::Canny(), dilateROI(), erodeROI(), qvipp::FastMarching(), qvipp::Inpaint(), qvipp::MinEigenVal(), QVImage< Type, Channels >::QVImage(), resetROI(), and setMarginROI().

void QVGenericImage::setMarginROI ( int  margin  )  [inline]

Sets the region of interest for an image, holding the whole image, except a border of a given width.

Parameters:
margin size of the border.

Definition at line 249 of file qvimage.h.

References getCols(), getRows(), and setROI().

void QVGenericImage::setROI ( const QRect &  rect  )  [inline]

Directly sets the region of interest for an image, with a given rectangle.

Parameters:
rect rectangle that represents region of interest.

Definition at line 255 of file qvimage.h.

References getCols(), getRows(), and roi.

void QVGenericImage::setAnchor ( int  col,
int  row 
) [inline]

Sets anchor to a given pixel coordinates.

Parameters:
col column of the pixel where the anchor is located.
row row of the pixel where the anchor is located.

Definition at line 275 of file qvimage.h.

Referenced by QVImage< Type, Channels >::QVImage(), and resetAnchor().

void QVGenericImage::setAnchor ( const QPoint &  point  )  [inline]

Directly sets anchor to a given pixel coordinates, given a point.

Parameters:
point QPoint where the anchor is located.

Definition at line 280 of file qvimage.h.

References anchor, getCols(), and getRows().

virtual const char* QVGenericImage::getTypeQString (  )  const [pure virtual]

Function to make introspection in the image, and obtain a char string identifying the type of the real image contained in the QVGenericImage.

Returns:
pointer to a constant char string identifying image type.

Implemented in QVImage< Type, Channels >, QVImage< Type, Channels >, QVImage< Type, Channels >, QVImage< Type, Channels >, QVImage< Type, Channels >, QVImage< Type, Channels >, and QVImage< Type, Channels >.

Referenced by isCompatibleWith().

bool QVGenericImage::isCompatibleWith ( const char *  qvImageClassName  )  const [inline]

Function to check whether an image is compatible with given image type id char string.

This functions checks if this image has same bit depth and channel number, as the type of QVGenericImage represented by the parameter string.

Id char string can be that returned by getTypeQString() function, from another QVGenericImage, or one specified by the programmer.

This function is used to dynamic type introspection, to determine subclass of a QVGenericImage, and perform different functionality with it, depending on bit depth or number of planes. An example code for this use is below:

 [...]
 QVImage image;

 [...]

 if(image->isCompatibleWith("QVImage<uChar,1>"))
        // do stuff with the uChar bit depth, one channel image ...
 else if(image->isCompatibleWith("QVImage<uChar,3>"))
        // do stuff with the uChar bit depth, three channel image ...
 [...]
 else
        // alternate code for that type of image ...

 [...] 

Parameters:
qvimageClassName char string identifying QVGenericImage type of an image.
Returns:
true if this image is compatible in type with that represented by the string.

Definition at line 323 of file qvimage.h.

Referenced by isCompatibleWith().

bool QVGenericImage::isCompatibleWith ( const QVGenericImage image  )  const [inline]

Function to check whether an image is compatible with this image.

This functions checks if this image is compatible with a given image (that is, it has same bit depth and same number of channels).

Id char string can be that returned by getTypeQString() function, from another QVGenericImage, or one specified by the programmer.

Parameters:
image image to check type with.
Returns:
true if this image is compatible in type with that represented by the string.

Definition at line 339 of file qvimage.h.

References getTypeQString(), and isCompatibleWith().


The documentation for this class was generated from the following file:
Generated on Wed Jan 16 18:41:29 2008 for QVision by  doxygen 1.5.3