Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

otImage Class Reference
[Image - Class for image store and processing, Image - Class for image store and processing]

Class for image store and processing.

#include <otImage.h>


Public Types

typedef otImage::ImageType ImageType
 < Image data type
enum  ImageType {
  IMG_U8, IMG_S8, IMG_U16, IMG_S16,
  IMG_U32, IMG_S32, IMG_U64, IMG_S64,
  IMG_F32, IMG_F64, IMG_RGB8 = IMG_U8 | 0x8000, IMG_RGB16 = IMG_U16 | 0x8000
}
 < Image data type More...

Public Member Functions

 otImage ()
bool create (U16 xSize, U16 ySize, U16 frames=1, ImageType type=IMG_U8)
bool create (otImage &src)
void close ()
bool blobsInit (U32 nBlobs)
U32 blobSearch (U16 frame, U16 threshold)
void blob (int i, rect &r)
void add (U32 immediate, S32 frame=-1)
void add (otImage &src, S32 frame=-1)
void accum (otImage &src, U32 frame=0)
void accum ()
void accumAverage (otImage &dst, U32 frame=0)
void shrink (otImage &dst, S32 frame=-1, U32 div=0)
void shrink (otImage &src, U32 min, F32 div)
void sub (U32 immediate, S32 frame=-1)
void sub (otImage &src, U32 immediate=0, S32 frame=-1)
void set (U32 immediate, S32 frame=-1)
F32 minMax (S32 frame=-1, U32 *Min=0, U32 *Max=0)
F32 stats (U16 sx, U16 sy, U16 wx, U16 wy, F32 &squareSum, F32 &sum, U32 frame=0)
F32 average (U16 sx, U16 sy, U16 wx, U16 wy, U32 frame=0)
F32 derivative (U16 sx, U16 sy, U16 wx, U16 wy, U32 frame=0, U32 offset=1023)
void derivative (U32 frame=0, U32 offset=1023)
void convolution (U16 sx, U16 sy, U16 wx, U16 wy, int *kernel, otImage &out)
U32 minimum ()
U32 maximum ()
F32 average ()
U32 frame ()
U32 frames ()
U16 width ()
U16 height ()
U8 type ()
bool isWordType ()
void * data (U32 frame=0)
Pixel pixel (U16 x, U16 y, U32 frame=0)
void setPixel (U16 x, U16 y, Pixel pix, U32 frame=0)
void copy (otImage &src)
void setGrabTime (U32 ms)
F32 fps ()
U32 size (bool absolute=true)
U32 pixels ()


Member Typedef Documentation

typedef otImage::ImageType otImage.ImageType
 


Member Enumeration Documentation

enum otImage::ImageType
 

Enumeration values:
IMG_U8  Unsigned 8 bit.
IMG_S8  Signed 8 bit.
IMG_U16  Unsigned 16 bit.
IMG_S16  Signed 16 bit.
IMG_U32  Unsigned 32 bit.
IMG_S32  Signed 32 bit.
IMG_U64  Unsigned 64 bit.
IMG_S64  Signed 64 bit.
IMG_F32  float
IMG_F64  double
IMG_RGB8  RGB unsigned 8 bit.
IMG_RGB16  RGB unsigned 16 bit.


Constructor & Destructor Documentation

otImage.otImage (   ) 
 

Create the class


Member Function Documentation

void otImage.accum (   ) 
 

Clear image accumulator

void otImage.accum (  otImage &  src,
U32  frame = 0
) 
 

It performs a sum of images with the same geometric characteristics but different types. In practice it is used to create an accumulator for averages and more.

Parameters:
src Image to add
frame Frame index of the source image

void otImage.accumAverage (  otImage &  dst,
U32  frame = 0
) 
 

Get the image average from the accumulator

Parameters:
dst Destination image for average image
frame Selected frame in destination image stack

void otImage.add (  otImage &  src,
S32  frame = -1
) 
 

Add to current image another one.

Parameters:
src Image to add. Specified image must be with the same geometric size and type.
frame Specify a frame or with -1 add to all stack.

void otImage.add (  U32  immediate,
S32  frame = -1
) 
 

Add to the image stack, or at a single frame, an immediate value.

Parameters:
immediate Value to add
frame Specify a frame or with -1 add to all stack.

F32 otImage.average (   ) 
 

Return the average value of the image

Returns:
The average

F32 otImage.average (  U16  sx,
U16  sy,
U16  wx,
U16  wy,
U32  frame = 0
) 
 

It performs average calculations on a defined area (ROI) of the image.

Parameters:
sx Start horizontal coordinate of the ROI
sy Start vertical coordinate of the ROI
wx Width of the ROI
wy Height of the ROI
frame Selected frame
Returns:
Average of the ROI

void otImage.blob (  int  i,
rect &  r
) 
 

Retrieve data of a detected blob

Parameters:
i Index of detected blob
r Data structure to store blob data

U32 otImage.blobSearch (  U16  frame,
U16  threshold
) 
 

Search blobs in the current image frame.

Parameters:
frame Index of the stack
threshold Used threshold for the detection.
Returns:
Number of detected blobs

bool otImage.blobsInit (  U32  nBlobs  ) 
 

A BLOB is a contiguous information area present in an image. It does not have a specific geometric shape, but each pixel that belongs to it has a common characteristic with all those belonging to the blob. This method init the class data for a specified maximum number of detect blobs.

Parameters:
nBlobs Specify the maximum number of detectable blobs.
Returns:
true on success

void otImage.close (   ) 
 

Close the class and free all allocated memory

void otImage.convolution (  U16  sx,
U16  sy,
U16  wx,
U16  wy,
int *  kernel,
otImage &  out
) 
 

Perform a kernel convolution with a 3x3 matrix

Parameters:
sx Start horizontal coordinate of the ROI
sy Start vertical coordinate of the ROI
wx Width of the ROI
wy Height of the ROI
kernel 3x3 matrix
out Output image, must with the same size of the ROI and the same data type

void otImage.copy (  otImage &  src  ) 
 

Copy an image. All stack is copied

Parameters:
src Image to be copied

bool otImage.create (  otImage &  src  ) 
 

Initialize the class with parameters taken from another existing class.

Parameters:
src Class used as a configuration, don't copy its contents
Returns:
true on success

bool otImage.create (  U16  xSize,
U16  ySize,
U16  frames = 1,
ImageType  type = IMG_U8
) 
 

Initialize the class with the specified parameters.

Parameters:
xSize Number of horizontal pixels
ySize Number of vertical pixels
frames Size of the image stack (number of frames)
type Image data type see ImageType
Returns:
true on success

void* otImage.data (  U32  frame = 0  ) 
 

Return image data pointer

Parameters:
frame Frame index of the stack
Returns:
Data pointer

void otImage.derivative (  U32  frame = 0,
U32  offset = 1023
) 
 

Calculate the derivative according to the following expression: Pix(x, y) = offset + Pix(x, y, frame + 1) - Pixel(x, y, frame)

Parameters:
frame Selected frame
offset Value to prevent underflow

F32 otImage.derivative (  U16  sx,
U16  sy,
U16  wx,
U16  wy,
U32  frame = 0,
U32  offset = 1023
) 
 

It performs average calculations of the following expression: avg = Sum(offset + Pix(x, y, frame + 1) - Pixel(x, y, frame)) / TotalPixels

Parameters:
sx Start horizontal coordinate of the ROI
sy Start vertical coordinate of the ROI
wx Width of the ROI
wy Height of the ROI
frame Selected frame
offset Value to prevent underflow
Returns:
Average of the ROI

F32 otImage.fps (   ) 
 

Return grab time as frame per second

Returns:
FPS

U32 otImage.frame (   ) 
 

Return selected frame

Returns:
Current frame

U32 otImage.frames (   ) 
 

Return number of frames of the stack

Returns:
Frames

U16 otImage.height (   ) 
 

Return vertical image pixels

Returns:
Image height

bool otImage.isWordType (   ) 
 

Return true when data type is greater then a byte

Returns:
True if data is a word

U32 otImage.maximum (   ) 
 

Return the maximum value of the image

Returns:
The maximum

U32 otImage.minimum (   ) 
 

Return the minimum value of the image

Returns:
The minimum

F32 otImage.minMax (  S32  frame = -1,
U32 *  Min = 0,
U32 *  Max = 0
) 
 

Find minimum, maximum and average of the image

Parameters:
frame Frame index of the stack or -1 for all stack
Min Pointer to variable to specify a start minimum value.
Max Pointer to variable to specify a start maximum value.
Returns:
Average value of the image

Pixel otImage.pixel (  U16  x,
U16  y,
U32  frame = 0
) 
 

Read a pixel

Parameters:
x Horizontal position
y Vertical position
frame Frame index of the stack
Returns:
Pixel value

U32 otImage.pixels (   ) 
 

Return the number of ipxels of the image

Returns:
Number of pixels

void otImage.set (  U32  immediate,
S32  frame = -1
) 
 

Set all image contents to a specified value.

Parameters:
immediate Value for all pixels
frame Set a specified frame of the stack or to all stack with -1

void otImage.setGrabTime (  U32  ms  ) 
 

Save the grab time for the image stack

Parameters:
ms Grab as milli seconds

void otImage.setPixel (  U16  x,
U16  y,
Pixel  pix,
U32  frame = 0
) 
 

Write a pixel

Parameters:
x Horizontal position
y Vertical position
pix Pixel value
frame Frame index of the stack

void otImage.shrink (  otImage &  src,
U32  min,
F32  div
) 
 

void otImage.shrink (  otImage &  dst,
S32  frame = -1,
U32  div = 0
) 
 

Convert image data to another format.

Parameters:
dst Image output, this must be allocated and with the geometric features
frame Frame index of the stack or -1 for all image stack
div Divider for range adjustment. Set 0 for automatic value.

U32 otImage.size (  bool  absolute = true  ) 
 

Return the size in bytes of all stack or of a single frame.

Parameters:
absolute True for all stack
Returns:
Size in bytes

F32 otImage.stats (  U16  sx,
U16  sy,
U16  wx,
U16  wy,
F32 &  squareSum,
F32 &  sum,
U32  frame = 0
) 
 

It performs some statistical calculations on a defined area (ROI) of the image.

Parameters:
sx Start horizontal coordinate of the ROI
sy Start vertical coordinate of the ROI
wx Width of the ROI
wy Height of the ROI
squareSum Sum of the square of all pixels
sum Sum of all pixels
frame Selected frame
Returns:
Average of the ROI

void otImage.sub (  otImage &  src,
U32  immediate = 0,
S32  frame = -1
) 
 

Subtract to current image another one.
image = image + immediate - src

Parameters:
src Image to subtract. Specified image must be with the same geometric size and type.
immediate An immediate value to add
frame Specify a frame or with -1 subtract to all stack.

void otImage.sub (  U32  immediate,
S32  frame = -1
) 
 

Subtract from the image stack, or at a single frame, an immediate value.

Parameters:
immediate Value to add
frame Specify a frame or with -1 subtract to all stack.

U8 otImage.type (   ) 
 

Return image data type

Returns:
Image type

U16 otImage.width (   ) 
 

Return horizontal image pixels

Returns:
Image width


The documentation for this class was generated from the following file: footer
otStudio - Library Reference - (C) 2020-25 Officina Turini, All Rights Reserved
Document built with Doxygen 1.4.0