class CImage

CImage implements an image of given size and depth (8bit, 16bit, 32bit) with an arbitrary number of equal sized image channels. More...

Definition#include <./CImage.h>
Template formCImage<class Type>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Members


Detailed Description

The origin of the image ogject is in the lower left corner. The class supports data sharing, e.g if image object A is assigned to image object B with B = A, both object share their channel data. Therefore, changing a pixel value in A causes the same change in B. Note that even if several channels are shared with other objects, further channels can be added to the the objects (e.g: A and B consist of 3 shared channels and C consist of 4 channels. After appending the channels of C to B with B.appendImage( C ), B consists of 7 channels; 3 channels shared with A and 4 channels shared with C. Single channels can be appended with appendChannel(..) or replaced with attachChannel(..). Both methods cause data sharing. Data sharing can be removed using detachChannel (e.g. if A=B with 3 channels. After A.detachChannel( 1 ), A is the exclusive owner of its second channel while the channels 0 and 2 remain shared). Using A.detachChannel() would make A to the exclusive owner of all of its channels. Use B = A.deepCopy(), if A should be assigned to B but data sharing should be avoided.

CImageChannel** ppChannels

ppChannels

[protected]

int iDepth

iDepth

[protected]

int iWidth

iWidth

[protected]

int iHeight

iHeight

[protected]

int iChannels

iChannels

[protected]

char acName[64]

acName[64]

[protected]

 CImage (int iWidth=1, int iHeight=1, int iChannels=1)

CImage

Constructs an image with specified number of channels and size.

Parameters:
iWidthWidth of image
iHeightHeight of image
iChannelsNumber of Channels

 CImage (const CImage& tSource)

CImage

Copy constructor

Parameters:
tSourceReference of instance to copy

 ~CImage ()

~CImage

Destructor

CImage&  operator= (const CImage& rSource)

operator=

Assign operator. Both images will share their channel data. Use deepCopy() to obtain a copy of an image which is not attached to the source image.

Parameters:
tSourceReference to source object.

CImage  convertTo32Bit ()

convertTo32Bit

[const]

Returns a copy of the object with depth 32 bit.

Returns: Copy of the object with depth 32 bit

CImage  convertTo16Bit ()

convertTo16Bit

[const]

Returns a copy of the object with depth 16 bit. Information may be lost!

Returns: Copy of the object with depth 16 bit

CImage  convertTo8Bit ()

convertTo8Bit

[const]

Returns a copy of the object with depth 8 bit. Information may be lost!

Returns: Copy of the object with depth 8 bit

CImage  deepCopy ()

deepCopy

[const]

Returns an exact copy of the object.

CImage  getRegion (int iX, int iY, int iRegWidth, int iRegHeight)

getRegion

[const]

Returns a multi-channel subregion of the image as an image object. The region is specified by the (x,y)-coordinate of the lower left corner and the region's width and height. Note that the region must be completely inside the image.

Parameters:
iXx-coordinate of upper left corner
iYy-coordinate of upper left corner
iWidthwidth of selected region
iHeightheight of selected region

Returns: Image of selected region

CImage  extractChannel (int iSrcChannel)

extractChannel

[const]

Extracts channel iSrcChannel to a new CImage. Both images will share the channel data (Shallow copy).

Parameters:
iSrcChannelSource channel

Returns: CImage with one channel

void  scaleRange (Type tMin, Type tMax, bool bChannelSpecific=false)

scaleRange

Scale pixel values from current min and max to new given min and max value. This operation can be applied to each channel separatly or to all channels at once. In the last case min and max of all channels are determined, while in the first case for all channels separatly. After the scaling operation the each channel or all channels have the new specified min and max value. (See CImageChannel:scaleRange for details)

Parameters:
tMin, tMax New min and max pixel value
bChannelSpecificIf true, the operation will be applied to each channel seperatly

void  scalelRange (vector NewMin, vector NewMax, vector Min, vector Max)

scalelRange

Scale pixel values from given min/max values to new min/max values. Values exceeding the given range are set to new min/max. (See CImageChannel:scaleRange for deatils)

Parameters:
NewMin, NewMax, New min/max values
Min, Max, Old min/max values

void  clipPercentage (float fMinClip, float fMaxClip, bool bChannelSpecific)

clipPercentage

Clips a given percentage of min/max intensity pixels. The intensity of the clipped pixels is set to the min/max of the remaining pixel.

Parameters:
fMinClip,fMaxClip Percentage of the pixels that should be clipped.
bChannelSpecificIf true, the operation will be applied to each channel seperatly

void  setChannelData (const Type* ptSource, int iChannel,int iOrigin=0)

setChannelData

Moves the data from the source to the specified image channel. The data has to be in row-by-row format.

Parameters:
ptSourcePointer to the source data
iChannelChannel to fill
iOriginSource data origin (0=lower left corner, 1=upper left corner)

void  getChannelData (Type* ptTarget, int iChannel)

getChannelData

[const]

Moves the data from the specified channel to the target The data will be in row-by-row order.

Parameters:
ptTargetPointer to the source data
iChannelChannel to fill

Type*  getChannelDataPtr (int iChannel)

getChannelDataPtr

[const]

Returns pointer to the specified channel data. This method allows direct access to the channel data memory. THIS METHOD ANNULS DATA ENCAPSULATION. DO NOT USE THIS METHOD S ANYMORE. IT WILL BE REMOVED IN FUTURE BECAUSE OF NEW DATA ORGNIZATION CONCEPTS.

Parameters:
iChannelChannel to get data from

void  getImageData (Type* ptTarget, bool bChannelOrder=true)

getImageData

[const]

Fills array with image data in pixel-by-pixel or channel-by-channel order

Parameters:
pTargetPointer to memory containing the image data
bChannelOrderedIf true, the image data is in channel order, otherwise in pixel order (default: true)

void  setImageData (Type* ptTarget, bool bChannelOrder=true, bool bFlipped=false)

setImageData

Sets image data for all channels using the data in an array. The data has to be in channel-by-channel or pixel-by-pixel order.

Parameters:
ptSourcePointer to memory containing the image data
bChannelOrderedIf true, the image data is assumed to be in channel order, otherwise in pixel order (default: true)
bFlippedIf true, the image data is assumed to begin in the upper left corner (default: false)

void  getPixel (int iX, int iY, Type* ptTarget)

getPixel

[const]

Gets the value of one pixel. The value of the pixel is an array of dimension equal to the number of channels of the image.

Parameters:
iXX coordinate of the pixel
iYY coordinate of the pixel
ptTargetPointer to memory that will be filled with the pixel data

void  setPixel (int iX, int iY, Type* ptSource)

setPixel

Sets the pixel at the specified position to a specified value. The value is an array of dimension equal to the number of channels.

Parameters:
iXX coordinate of the pixel
iYY coordinate of the pixel
ptSourcePointer to memory that contains the data to set

void  setPixel (int iX, int iY, int iChannel,Type tValue)

setPixel

Sets the pixel at the specified position in the specified channel to a new value.

Parameters:
iXX coordinate of the pixel
iYY coordinate of the pixel
iChannelChannel index of the point
tValueNew value of the specified point

void  getRegion (int iX, int iY, int iChannel,int iRegionWidth, int iRegionHeight, Type* ptRegion)

getRegion

[const]

Returns a subregion of an image channel. The region is specified by the (x,y)-coordinate of the lower left corner, the region's width and height and the channel index.

Parameters:
iXx-coordinate of upper left corner
iYy-coordinate of upper left corner
iChannelchannel index
iWidthwidth of selected region
iHeightheight of selected region
ptRegionPtr to memory to be filled with image data

void  fillChannel (const CImage& tSrc, int iSrcChannel, int iTargetChannel)

fillChannel

Copies image data of pSrc's channel iSrcChannel to channel iTargetChannel

Parameters:
tSrcReference to source image
iSrcChannelSource channel
iTargetChannelTarget channel

void  removeChannel (int iChannel)

removeChannel

Removes a specified channel.

Parameters:
iChannelIndex of channel to remove

void  appendImage (const CImage& pSrc)

appendImage

Append channels of pSrc to the existing channels. Both objects will share their data. Note the width and height of both images must be equal.

Parameters:
pChannelReference to instance of CImage

void  swapChannels (int iIndexA, int iIndexB)

swapChannels

Swaps channel iIndexA and iIndexB

Parameters:
iIndexAIndex of channel A;
iIndexBIndex of channel B

void  setName (char* acName)

setName

const char*  getName ()

getName

[const]

void  setChannelInfo (const char* pcText, int iChannel)

setChannelInfo

Modifies the info of a specified channel (max 63 chars).

Parameters:
pcTextString containing the info text
iChannelIndex of channel

const char*  getChannelInfo (int iChannel)

getChannelInfo

[const]

Returns a pointer to the info text of a channel

Parameters:
iChannelIndex of channel

Returns: Pointer to info text.

void  resize (int iWidth, int iHeight,int iChannels)

resize

Changes size and number of image channels. If only the number of channels is incremented, the data of the already existing channels will be remain unchanged and the new channels will be initialized with zeros. If the number of channels is reduced, channels will be deleted while the data of remaining channels will be unchanged. If the width and/or height is changed all data will be destroyed. Shared channels will be detached automatically before resizing.

Parameters:
iWidthNew image width
iHeightNew image height
iChannelsNew number of channels

void  clear (int iChannel=-1)

clear

Sets the pixels of one or all channels to zero

Parameters:
iChannelChannel to fill with zero (default: -1 = all)

void  cloneChannel (int iSrcChannel,CImage* pTgtImage, int iTgtChannel)

cloneChannel

Copys the image data from a specified channel to a specified channel of a seccond image.

Parameters:
iSrcChannelIndex of channel to clone
pTgtImagePointer to targetimage
iTgtChannelIndex of channel to be filled with the imagedata

inline int  depth ()

depth

[const]

Returns depth of the image channels.

Returns: Depth of image channels

inline int  pixels ()

pixels

Returns number of pixels in the images

Returns: Number of pixels

inline int  pixelsPerChannel ()

pixelsPerChannel

Returns number of pixels in each channel

Returns: Number of pixels in each channel

int  channels ()

channels

[const]

Returns number of the image channels.

Returns: Number of image channels

int  width ()

width

[const]

Returns image width.

Returns: Width

int  height ()

height

[const]

Returns image height.

Returns: Height

int  getFilteredPixel (int iX, int iY, bool* pbMask,Type* ptTarget)

getFilteredPixel

[const]

Gets a pixel pillar of the channels specified by the mask pbMask.

Parameters:
iXX coordinate of the pixel
iYY coordinate of the pixel
pbMaskArray (dim = #channels) of bool values that select/deselect channels (true = selected, false = deselected).
ptTargetPointer to memory that will be filled with the pixel data

Returns: Number of elements filled in ptTarget

Type  getPixel (int iX, int iY, int iChannel=0)

getPixel

[const]

Insteed of the previous version of getPixel(..), this version returns the value at the specified position in the specified channel.

Parameters:
iXX coordinate of the pixel
iYY coordinate of the pixel
iChannelChannel index (default 0)

Returns: Value of specified point

Type  max (int iChannel)

max

[const]

Returns max pixel value of channel iChannel

Parameters:
iChannelIndex of channel

Type  min (int iChannel)

min

[const]

Returns min pixel value of channel iChannel

Parameters:
iChannelIndex of channel

vector  histogram (int iChannel, float fMin, float fMax, int iNbBins)

histogram

[const]

Calculates a histogram given min, max, #bins

Parameters:
iChannelChannel number for histogram
fMinMinimum bin value
fMaxMaximum bin value
iNbBinsNumber of bins

Type  interpolate (float fX, float fY,int iChannel=0)

interpolate

[const]

Bilinear interpolation for 'subpixel' values.

Parameters:
fXX coordinate of the pixel
fYY coordinate of the pixel
iChannelChannel index (default 0)

Returns: Value of the specified point

char*  describe ()

describe

[const]

Returns: description string for image.

CImage*  copy (CImage *pTo=0)

copy

[const]

Create copy of image. Reuse instance pTo if specified.

Returns: pointer to create image or pTo.

bool  isAttached ()

isAttached

[const]

Returns true if one or more channels are shared between several objects.

Returns: True if channel data is shared

void  detach (int iIndex = -1)

detach

[const]

Makes the image to the only owner of the channel data (if iIndex = -1). If iIndex is an legal channel index only the corresponding channel will be detached.

void  attachChannel (int iThisChannel, int iThatChannel, const CImage& rtThatImage)

attachChannel

Attachs the channel iThisChannel to the channel iThatChannel of the object rtThatImage. Both images must have the same width and height.

Parameters:
iThisChannelChannel index to attach
iThatChannelChannel index to attach to.
rtThatImageImage object containing rtThatImage

void  appendChannel (int iChannel, const CImage& rtThatImage)

appendChannel

Appends the channel iChannel of image rtImage to the image. The images must have the same width and height. Both image will share their data.

Parameters:
iThisChannelChannel index to append
rtImageImage object containing rtThatImageproviding the channel

Type*  getChannelPtr (int iIndex)

getChannelPtr

[const]

Returns pointer to the specified channel data. This method allows direct access to the channel data memory. THIS METHOD ANNULS DATA ENCAPSULATION. DO NOT USE THIS METHOD S ANYMORE. IT WILL BE REMOVED IN FUTURE BECAUSE OF NEW DATA ORGNIZATION CONCEPTS.

Parameters:
iChannelChannel to get data from

void  findMinMax (Type& tMin, Type& tMax)

findMinMax

[const]

Detects the minimal and maximal value regarding all channels

CImage  rotate (float fAngle, int fXOrigin = -1, int fYOrigin = -1)

rotate

Rotate image by angle fAngle (degree) with origin (fXOrigin, fYOrigin) If origin is equal to (-1,-1), the image center will be used.

Parameters:
fAngleAngle in degree
fXOriginx-coordinate of rotation origin
fYOriginy-coordinate of rotation origin

CImage  scale (float fFactor, TScaleMethod method)

scale

[const]

Scale image by factor fFactor. Using different methods (Simple, BiLinInter, Average) According to the selected method the pixels in the returned image are build of one pixel (simple), bilinear interpolation of four pixels (BiLinInter) or the average of a region (average) from the source image.

Parameters:
fFactorScaling factor
methodScaling method