Image Component Library (ICL)
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members

The ImgParams class stores all image parameters . More...

#include <ImgParams.h>

Public Member Functions

 ImgParams ()
 creates a null ImgParams object More...
 
 ImgParams (const ImgParams &params)
 copy constructor More...
 
 ImgParams (const utils::Size &size, int channels, const utils::Rect &roi=utils::Rect::null)
 creates an ImgParams object with specified size, channels, roi and formatMatrix More...
 
 ImgParams (const utils::Size &size, format fmt, const utils::Rect &roi=utils::Rect::null)
 creates an ImgParams object with specified size, channels, roi and format More...
 
 ImgParams (const utils::Size &size, int channels, format fmt, const utils::Rect &roi=utils::Rect::null)
 creates an ImgParams object with all given parameters More...
 
 ImgParams (int width, int height, format fmt, int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0)
 creates an ImgParams object with specified size, format and roi given as POD-Types More...
 
 ImgParams (int width, int height, int channels, int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0)
 creates an ImgParams object with specified size, channel and roi given as POD-Types More...
 
 ImgParams (int width, int height, int channels, format fmt, int roiX=0, int roiY=0, int roiWidth=0, int roiHeight=0)
 creates an ImgParams object with ALL possible parameters More...
 
bool isNull () const
 checks wether the object instance is null, i.e. all elements are zero More...
 
bool operator!= (const ImgParams &other) const
 returns !(*this==other) More...
 
bool operator== (const ImgParams &other) const
 test is all parameters (size, roi, channels, format) are identical More...
 
void setSize (const utils::Size &size)
 sets the size to the current value (and resets the roi to null) More...
 
void setFormat (format fmt)
 sets the format to the given format (the channel count is adapted on demand) More...
 
void setChannels (int channels)
 sets the channels to the given channel count (format is set to "formatMatrix" on demand) More...
 
void setROIOffset (const utils::Point &offset)
 sets the image ROI offset to the given value More...
 
void setROISize (const utils::Size &roisize)
 sets the image ROI size to the given value More...
 
void setROI (const utils::Point &offset, const utils::Size &roisize)
 set both image ROI offset and size More...
 
void setROI (const utils::Rect &roi)
 sets the image ROI to the given rectangle More...
 
void setROIOffsetAdaptive (const utils::Point &offset)
 checks, eventually adapts and finally sets the image ROI offset More...
 
void setROISizeAdaptive (const utils::Size &size)
 checks, eventually adapts and finally sets the image ROI size More...
 
void setROIAdaptive (const utils::Rect &r)
 as setROI, but if checks for negative parameters More...
 
utils::RectadaptROI (utils::Rect &roi) const
 adapt given ROI, such that it fits for the current ImgParams More...
 
bool hasFullROI () const
 returns ROISize == ImageSize More...
 
void setFullROI ()
 sets the ROI to 0,0,image-width,image-height More...
 
const utils::SizegetSize () const
 returns the objects size More...
 
int getChannels () const
 returns the objects channel count More...
 
format getFormat () const
 returns the object format More...
 
const utils::RectgetROI () const
 returns the objects ROI rect More...
 
void getROI (utils::Point &offset, utils::Size &size) const
 copies the roi parameters into the given structs offset and size More...
 
const utils::Point getROIOffset () const
 returns the objects ROI offset More...
 
const utils::Size getROISize () const
 returns the objects ROI size More...
 
int getWidth () const
 returns the objects image width More...
 
int getHeight () const
 return the objects image height More...
 
int getPixelOffset () const
 returns ROI-dependent pixel offset, to address the upper left ROI pixel More...
 
int getROIWidth () const
 returns the ROI width of the object More...
 
int getROIHeight () const
 returns the ROI height of the object More...
 
int getROIXOffset () const
 returns the ROI X-Offset of the object More...
 
int getROIYOffset () const
 returns the ROI Y-Offset of the object More...
 
int getDim () const
 returns the count of image pixels (width*height) More...
 
int getROIDim () const
 returns the count of ROI pixels ( ROI_width*ROI_height ) More...
 

Static Public Attributes

static const ImgParams null
 as default size=(0,0), channels=0, format=matrix, roi=(0,0,0,0) More...
 

Private Member Functions

void setup (const utils::Size &size, format fmt, int channels, const utils::Rect &roi)
 initialisation function More...
 

Private Attributes

utils::Size m_oSize
 image size More...
 
int m_iChannels
 image channel count More...
 
format m_eFormat
 image format (formatRGB, formatMatrix, ...) More...
 
utils::Rect m_oROI
 image roi More...
 

Detailed Description

The ImgParams class stores all image parameters .

This class offers an encapsulation of all Img parameters

The class helps to create image processing classes getting certain image parameters. This parameters can now directly be aquired from an ImgBase object. In addition to this, except to the ImgBases underlying depth (which is commited to the depth of the underlying Img object) Images can be made compatible by calling imageA.setParams(imageB.getParams())

Constructor & Destructor Documentation

◆ ImgParams() [1/8]

icl::core::ImgParams::ImgParams ( )
inline

creates a null ImgParams object

See also
setup
null

◆ ImgParams() [2/8]

icl::core::ImgParams::ImgParams ( const ImgParams params)
inline

copy constructor

See also
setup

◆ ImgParams() [3/8]

icl::core::ImgParams::ImgParams ( const utils::Size size,
int  channels,
const utils::Rect roi = utils::Rect::null 
)
inline

creates an ImgParams object with specified size, channels, roi and formatMatrix

See also
setup

◆ ImgParams() [4/8]

icl::core::ImgParams::ImgParams ( const utils::Size size,
format  fmt,
const utils::Rect roi = utils::Rect::null 
)

creates an ImgParams object with specified size, channels, roi and format

See also
setup

◆ ImgParams() [5/8]

icl::core::ImgParams::ImgParams ( const utils::Size size,
int  channels,
format  fmt,
const utils::Rect roi = utils::Rect::null 
)
inline

creates an ImgParams object with all given parameters

Note that channels and format are not independent. Hence, if the given channel count is not compatible to the given format, an exception is thrown.

See also
setup

◆ ImgParams() [6/8]

icl::core::ImgParams::ImgParams ( int  width,
int  height,
format  fmt,
int  roiX = 0,
int  roiY = 0,
int  roiWidth = 0,
int  roiHeight = 0 
)

creates an ImgParams object with specified size, format and roi given as POD-Types

channel count is adapted to the given format

See also
setup

◆ ImgParams() [7/8]

icl::core::ImgParams::ImgParams ( int  width,
int  height,
int  channels,
int  roiX = 0,
int  roiY = 0,
int  roiWidth = 0,
int  roiHeight = 0 
)

creates an ImgParams object with specified size, channel and roi given as POD-Types

The format is set to "formatMatrix"

See also
setup

◆ ImgParams() [8/8]

icl::core::ImgParams::ImgParams ( int  width,
int  height,
int  channels,
format  fmt,
int  roiX = 0,
int  roiY = 0,
int  roiWidth = 0,
int  roiHeight = 0 
)

creates an ImgParams object with ALL possible parameters

Note that channels and format are not independent. Hence, if the given channel count is not compatible to the given format, an exception is thrown.

See also
setup

Member Function Documentation

◆ adaptROI()

utils::Rect& icl::core::ImgParams::adaptROI ( utils::Rect roi) const

adapt given ROI, such that it fits for the current ImgParams

See also
setROIAdaptive

◆ getChannels()

int icl::core::ImgParams::getChannels ( ) const
inline

returns the objects channel count

◆ getDim()

int icl::core::ImgParams::getDim ( ) const
inline

returns the count of image pixels (width*height)

◆ getFormat()

format icl::core::ImgParams::getFormat ( ) const
inline

returns the object format

◆ getHeight()

int icl::core::ImgParams::getHeight ( ) const
inline

return the objects image height

◆ getPixelOffset()

int icl::core::ImgParams::getPixelOffset ( ) const
inline

returns ROI-dependent pixel offset, to address the upper left ROI pixel

◆ getROI() [1/2]

const utils::Rect& icl::core::ImgParams::getROI ( ) const
inline

returns the objects ROI rect

◆ getROI() [2/2]

void icl::core::ImgParams::getROI ( utils::Point offset,
utils::Size size 
) const
inline

copies the roi parameters into the given structs offset and size

◆ getROIDim()

int icl::core::ImgParams::getROIDim ( ) const
inline

returns the count of ROI pixels ( ROI_width*ROI_height )

◆ getROIHeight()

int icl::core::ImgParams::getROIHeight ( ) const
inline

returns the ROI height of the object

◆ getROIOffset()

const utils::Point icl::core::ImgParams::getROIOffset ( ) const
inline

returns the objects ROI offset

◆ getROISize()

const utils::Size icl::core::ImgParams::getROISize ( ) const
inline

returns the objects ROI size

◆ getROIWidth()

int icl::core::ImgParams::getROIWidth ( ) const
inline

returns the ROI width of the object

◆ getROIXOffset()

int icl::core::ImgParams::getROIXOffset ( ) const
inline

returns the ROI X-Offset of the object

◆ getROIYOffset()

int icl::core::ImgParams::getROIYOffset ( ) const
inline

returns the ROI Y-Offset of the object

◆ getSize()

const utils::Size& icl::core::ImgParams::getSize ( ) const
inline

returns the objects size

◆ getWidth()

int icl::core::ImgParams::getWidth ( ) const
inline

returns the objects image width

◆ hasFullROI()

bool icl::core::ImgParams::hasFullROI ( ) const
inline

returns ROISize == ImageSize

◆ isNull()

bool icl::core::ImgParams::isNull ( ) const
inline

checks wether the object instance is null, i.e. all elements are zero

◆ operator!=()

bool icl::core::ImgParams::operator!= ( const ImgParams other) const
inline

returns !(*this==other)

◆ operator==()

bool icl::core::ImgParams::operator== ( const ImgParams other) const

test is all parameters (size, roi, channels, format) are identical

◆ setChannels()

void icl::core::ImgParams::setChannels ( int  channels)

sets the channels to the given channel count (format is set to "formatMatrix" on demand)

◆ setFormat()

void icl::core::ImgParams::setFormat ( format  fmt)

sets the format to the given format (the channel count is adapted on demand)

◆ setFullROI()

void icl::core::ImgParams::setFullROI ( )
inline

sets the ROI to 0,0,image-width,image-height

◆ setROI() [1/2]

void icl::core::ImgParams::setROI ( const utils::Point offset,
const utils::Size roisize 
)

set both image ROI offset and size

This function evaluates if the new offset is inside of the image, as well as if the resulting roi does fit into the image.

◆ setROI() [2/2]

void icl::core::ImgParams::setROI ( const utils::Rect roi)
inline

sets the image ROI to the given rectangle

◆ setROIAdaptive()

void icl::core::ImgParams::setROIAdaptive ( const utils::Rect r)

as setROI, but if checks for negative parameters

While the methods setROI, setROIOffset and setROISize directly set the images ROI from the given arguments (if possible), the following methods adapt the ROI parameters to assure a valid ROI. Negative values are interpreted relative to the whole image size resp. the lower right corner of the image.

E.g. an offset (5,5) with size (-10,-10) sets the ROI to the inner sub image with a 5-pixel margin. offset(-5,-5) and size (5,5) sets the ROI to the lower right 5x5 corner.

◆ setROIOffset()

void icl::core::ImgParams::setROIOffset ( const utils::Point offset)

sets the image ROI offset to the given value

If the offset is not inside of the image or the new offset causes the roi not to fit into the image, nothing is done, and an exception is thrown.

◆ setROIOffsetAdaptive()

void icl::core::ImgParams::setROIOffsetAdaptive ( const utils::Point offset)

checks, eventually adapts and finally sets the image ROI offset

◆ setROISize()

void icl::core::ImgParams::setROISize ( const utils::Size roisize)

sets the image ROI size to the given value

If the new roi size causes the roi not to fit into the image, nothing is done and an exception is thrown

◆ setROISizeAdaptive()

void icl::core::ImgParams::setROISizeAdaptive ( const utils::Size size)

checks, eventually adapts and finally sets the image ROI size

◆ setSize()

void icl::core::ImgParams::setSize ( const utils::Size size)

sets the size to the current value (and resets the roi to null)

◆ setup()

void icl::core::ImgParams::setup ( const utils::Size size,
format  fmt,
int  channels,
const utils::Rect roi 
)
private

initialisation function

The initialisation function does all the magic that is necessary to setup all parameters correctly. There are two issues, that must be treated in a special way:

  1. size must be positive in [0,inf) x [0,inf)
  2. set up the format and channel count correctly
  3. ensure, that the roi has a valid size and position

Format and Channel Count

The parameters format and channel count depend on each other. The channel count is fixed and well defined for all allowed formats except "formatMatrix", where the channel count is arbitrary including zero. So, if the given format distincts from formatMatrix, the given channel count is disobeyed and the objects channel count is set to the channel count associated with the given format (e.g. the "formatRGB" has three channels). The association is performed by the global icl-namespace function getChannelsOfFormat (see the functions documentation for more details. If the given format is "formatMatrix", then the channel count is checked to be positive (in [0,inf)) to avoid errors, that would occur, if e.g. -5 channels are allocated at runtime.

Ensure a Valid ROI Size

In total, there are three problems, that need to be tackled when the ROI is set.

  • Check if the given roi is null: if the given roi is null (this means the rect has offset (0,0) and size (0,0)), then the objects ROI is set up to cover the whole image rect (offset (0,0) and size (image-width,image-height)). If it is not null, the following two issues must be regarded.
  • Check if the given offset is inside of the image: This should be self-evident. If the offset is outside the image rect, it is set to (0,0), and furthermore a specific exception is thrown.
  • Check if the given roi size is valid: This can be devided into two parts:
    1. The ROI size must be positive (in [0,inf) x [0,inf)). If not, the roi is set to null (whole image) and an error is thrown.
    2. The ROI must fit into the image. Otherwise the ROI is set to null (whole image) and an error is thrown.

Member Data Documentation

◆ m_eFormat

format icl::core::ImgParams::m_eFormat
private

image format (formatRGB, formatMatrix, ...)

◆ m_iChannels

int icl::core::ImgParams::m_iChannels
private

image channel count

◆ m_oROI

utils::Rect icl::core::ImgParams::m_oROI
private

image roi

◆ m_oSize

utils::Size icl::core::ImgParams::m_oSize
private

image size

◆ null

const ImgParams icl::core::ImgParams::null
static

as default size=(0,0), channels=0, format=matrix, roi=(0,0,0,0)


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