zz::detail::ImageBase< _Tp > Class Template Reference

Base image storage class This defines the storage and pixel-wise access to a image like 3-D matrix. More...

#include <zupply.hpp>

Public Types

typedef _Tp value_type
 

Public Member Functions

 ImageBase ()
 ImageBase Default(empty) constructor.
 
 ImageBase (int rows, int cols, int channels)
 ImageBase Constructor with size info. More...
 
 ImageBase (const ImageBase &other)
 ImageBase Copy constructor(shallow copy) More...
 
 ImageBase (ImageBase &&other)
 ImageBase Move constructor. More...
 
void create (int rows, int cols, int channels)
 create Create storage with specified size More...
 
void release ()
 release Destroy memory storage
 
ImageBaseoperator= (const ImageBase &other)
 operator = Copy operator, again, shallow copy More...
 
ImageBaseoperator= (ImageBase &&other)
 operator = Move operator More...
 
_Tp & operator() (int row, int col, int channel=0)
 operator () Access pixel element More...
 
const _Tp & operator() (int row, int col, int channel=0) const
 operator () Access pixel element, immutable version More...
 
template<typename _Tp2 >
 operator ImageBase< _Tp2 > () const
 
bool empty () const
 empty Check empty or not More...
 
int rows () const
 rows Get number of rows(height, y...) More...
 
int cols () const
 cols Get number of columns(width, x...) More...
 
int channels () const
 channels Get number of channels More...
 
_Tp at (int row, int col, int channel=0) const
 at Access pixel, immutable version. This is guanranteed to be faster than () operator if you don't need to modify data. More...
 
_Tp * ptr (int offset=0) const
 ptr Data pointer given specifed position. Use with cautious. This is provided for performance consideration. Will not trigger copy-on-write method, so if you change the data, the previous copied images will be affected. More...
 
_Tp * ptr (int row, int col, int channel=0) const
 ptr Data pointer given specifed position. Use with cautious. This is provided for performance consideration. Will not trigger copy-on-write method, so if you change the data, the previous copied images will be affected. More...
 
void import (_Tp *data, int rows, int cols, int channels)
 import Import data from raw pointer array. Please make sure the length of array satisfies the size provided. More...
 
void import (std::vector< _Tp > data, int rows, int cols, int channels)
 import Import data from vector. Please make sure the length of vector satisfies the size provided. More...
 
std::vector< _Tp > export_raw () const
 
template<typename _Tp2 >
std::vector< _Tp2 > & export_raw (std::vector< _Tp2 > &out) const
 export data to provided vector container.
 
void crop (int r0, int c0, int r1, int c1)
 crop Crop image given coordinates. More...
 
void crop (Point p0, Point p1)
 crop Crop image given two points More...
 
void crop (Rect rect)
 crop Crop image given a rectangle area. More...
 

Protected Member Functions

void range_check (long long pos) const
 
void range_check (int row, int col, int channel) const
 
void detach ()
 

Protected Attributes

int rows_
 
int cols_
 
int channels_
 
std::shared_ptr< std::vector< _Tp > > data_
 

Detailed Description

template<typename _Tp>
class zz::detail::ImageBase< _Tp >

Base image storage class This defines the storage and pixel-wise access to a image like 3-D matrix.

Constructor & Destructor Documentation

template<typename _Tp>
zz::detail::ImageBase< _Tp >::ImageBase ( int  rows,
int  cols,
int  channels 
)

ImageBase Constructor with size info.

Parameters
rows
cols
channels
template<typename _Tp>
zz::detail::ImageBase< _Tp >::ImageBase ( const ImageBase< _Tp > &  other)

ImageBase Copy constructor(shallow copy)

Note
ImageBase use Copy-on-write technique, so you don't need to worry about the deep/shallow copy issue.
Parameters
other
template<typename _Tp>
zz::detail::ImageBase< _Tp >::ImageBase ( ImageBase< _Tp > &&  other)

ImageBase Move constructor.

Parameters
other

Member Function Documentation

template<typename _Tp>
_Tp zz::detail::ImageBase< _Tp >::at ( int  row,
int  col,
int  channel = 0 
) const

at Access pixel, immutable version. This is guanranteed to be faster than () operator if you don't need to modify data.

Parameters
row
col
channel
Returns
Pixel value
template<typename _Tp>
int zz::detail::ImageBase< _Tp >::channels ( ) const

channels Get number of channels

Returns
Number of channels
template<typename _Tp>
int zz::detail::ImageBase< _Tp >::cols ( ) const

cols Get number of columns(width, x...)

Returns
Number of columns(width, x...)
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::create ( int  rows,
int  cols,
int  channels 
)

create Create storage with specified size

Parameters
rows
cols
channels
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::crop ( int  r0,
int  c0,
int  r1,
int  c1 
)

crop Crop image given coordinates.

Parameters
r0
c0
r1
c1
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::crop ( Point  p0,
Point  p1 
)

crop Crop image given two points

Parameters
p0
p1
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::crop ( Rect  rect)

crop Crop image given a rectangle area.

Parameters
rect
template<typename _Tp>
bool zz::detail::ImageBase< _Tp >::empty ( ) const

empty Check empty or not

Returns
True if empty
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::import ( _Tp *  data,
int  rows,
int  cols,
int  channels 
)

import Import data from raw pointer array. Please make sure the length of array satisfies the size provided.

Parameters
data
rows
cols
channels
template<typename _Tp>
void zz::detail::ImageBase< _Tp >::import ( std::vector< _Tp >  data,
int  rows,
int  cols,
int  channels 
)

import Import data from vector. Please make sure the length of vector satisfies the size provided.

Parameters
data
rows
cols
channels
template<typename _Tp>
template<typename _Tp2 >
zz::detail::ImageBase< _Tp >::operator ImageBase< _Tp2 > ( ) const

Conver to another data type, using saturate_cast<>

template<typename _Tp>
_Tp& zz::detail::ImageBase< _Tp >::operator() ( int  row,
int  col,
int  channel = 0 
)

operator () Access pixel element

Parameters
row
col
channel
Returns
template<typename _Tp>
const _Tp& zz::detail::ImageBase< _Tp >::operator() ( int  row,
int  col,
int  channel = 0 
) const

operator () Access pixel element, immutable version

Parameters
row
col
channel
Returns
template<typename _Tp>
ImageBase& zz::detail::ImageBase< _Tp >::operator= ( const ImageBase< _Tp > &  other)

operator = Copy operator, again, shallow copy

Parameters
other
Returns
template<typename _Tp>
ImageBase& zz::detail::ImageBase< _Tp >::operator= ( ImageBase< _Tp > &&  other)

operator = Move operator

Parameters
other
Returns
template<typename _Tp>
_Tp* zz::detail::ImageBase< _Tp >::ptr ( int  offset = 0) const

ptr Data pointer given specifed position. Use with cautious. This is provided for performance consideration. Will not trigger copy-on-write method, so if you change the data, the previous copied images will be affected.

Parameters
offset
Returns
Raw pointer to specific data point
template<typename _Tp>
_Tp* zz::detail::ImageBase< _Tp >::ptr ( int  row,
int  col,
int  channel = 0 
) const

ptr Data pointer given specifed position. Use with cautious. This is provided for performance consideration. Will not trigger copy-on-write method, so if you change the data, the previous copied images will be affected.

Parameters
row
col
channel
Returns
template<typename _Tp>
int zz::detail::ImageBase< _Tp >::rows ( ) const

rows Get number of rows(height, y...)

Returns
Number of rows(height, y...)

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