The View structure provides storage and manipulation of images.
More...
|
enum | Format {
None = 0,
Gray8,
Uv16,
Bgr24,
Bgra32,
Int16,
Int32,
Int64,
Float,
Double,
BayerGrbg,
BayerGbrg,
BayerRggb,
BayerBggr,
Hsv24,
Hsl24
} |
|
enum | Position {
TopLeft,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
} |
|
typedef A< uint8_t > | Allocator |
|
|
| View () |
|
| View (const View &view) |
|
| View (const cv::Mat &mat) |
|
| View (size_t w, size_t h, ptrdiff_t s, Format f, void *d) |
|
| View (size_t w, size_t h, Format f, void *d=NULL, size_t align=Allocator::Alignment()) |
|
| View (const Point< ptrdiff_t > &size, Format f) |
|
| ~View () |
|
| operator cv::Mat () const |
|
View * | Clone () const |
|
View & | operator= (const View &view) |
|
View & | operator= (const cv::Mat &mat) |
|
View & | Ref () |
|
void | Recreate (size_t w, size_t h, Format f, void *d=NULL, size_t align=Allocator::Alignment()) |
|
void | Recreate (const Point< ptrdiff_t > &size, Format f) |
|
View | Region (ptrdiff_t left, ptrdiff_t top, ptrdiff_t right, ptrdiff_t bottom) const |
|
View | Region (const Point< ptrdiff_t > &topLeft, const Point< ptrdiff_t > &bottomRight) const |
|
View | Region (const Rectangle< ptrdiff_t > &rect) const |
|
View | Region (const Point< ptrdiff_t > &size, Position position) const |
|
View | Flipped () const |
|
Point< ptrdiff_t > | Size () const |
|
size_t | DataSize () const |
|
size_t | Area () const |
|
template<class T > |
const T & | At (size_t x, size_t y) const |
|
template<class T > |
T & | At (size_t x, size_t y) |
|
template<class T > |
const T & | At (const Point< ptrdiff_t > &p) const |
|
template<class T > |
T & | At (const Point< ptrdiff_t > &p) |
|
size_t | PixelSize () const |
|
size_t | ChannelSize () const |
|
size_t | ChannelCount () const |
|
void | Swap (View &other) |
|
bool | Load (const std::string &path) |
|
bool | Save (const std::string &path) const |
|
|
const size_t | width |
| A width of the image.
|
|
const size_t | height |
| A height of the image.
|
|
const ptrdiff_t | stride |
| A row size of the image in bytes.
|
|
const Format | format |
| A pixel format types of the image.
|
|
uint8_t *const | data |
| A pointer to the pixel data (first row) of the image.
|
|
template<template< class > class A>
struct Simd::View< A >
The View structure provides storage and manipulation of images.
In order to have mutual conversion with OpenCV image type (cv::Mat) you have to define macro SIMD_OPENCV_ENABLE: #include "opencv2/core/core.hpp"
#define SIMD_OPENCV_ENABLE
#include "Simd/SimdView.hpp"
int main()
{
typedef Simd::View<Simd::Allocator> View;
View view1(40, 30, View::Bgr24);
cv::Mat mat1(80, 60, CV_8UC3)
View view2 = mat1; // view2 will be refer to mat1, it is not a copy!
cv::Mat mat2 = view1; // mat2 will be refer to view1, it is not a copy!
return 0;
}
Related Functions.
Creates a new empty View structure.
Creates a new View structure on the base of the image view.
- Note
- This constructor is not create new image view! It only creates a reference to the same image. If you want to create a copy then must use method Simd::View::Clone.
- Parameters
-
[in] | view | - an original image view. |
SIMD_INLINE View |
( |
const cv::Mat & |
mat | ) |
|
Creates a new View structure on the base of OpenCV Mat type.
- Note
- You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
- Parameters
-
SIMD_INLINE View |
( |
size_t |
w, |
|
|
size_t |
h, |
|
|
ptrdiff_t |
s, |
|
|
Format |
f, |
|
|
void * |
d |
|
) |
| |
Creates a new View structure with specified width, height, row size, pixel format and pointer to pixel data.
- Parameters
-
[in] | w | - a width of created image view. |
[in] | h | - a height of created image view. |
[in] | s | - a stride (row size) of created image view. |
[in] | f | - a pixel format of created image view. |
[in] | d | - a pointer to the external buffer with pixel data. If this pointer is NULL then will be created own buffer. |
Creates a new View structure with specified width, height, pixel format, pointer to pixel data and memory alignment.
- Parameters
-
[in] | w | - a width of created image view. |
[in] | h | - a height of created image view. |
[in] | f | - a pixel format of created image view. |
[in] | d | - a pointer to the external buffer with pixel data. If this pointer is NULL then will be created own buffer. |
[in] | align | - a required memory alignment. Its default value is determined by function Allocator::Alignment. |
Creates a new View structure with specified width, height and pixel format.
- Parameters
-
[in] | size | - a size (width and height) of created image view. |
[in] | f | - a pixel format of created image view. |
SIMD_INLINE operator cv::Mat |
( |
| ) |
const |
Creates an OpenCV Mat which references this image.
- Note
- You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
- Returns
- an OpenCV Mat which references to this image.
SIMD_INLINE View< A > * Clone |
( |
| ) |
const |
Gets a copy of current image view.
- Returns
- a pointer to the new View structure. The user must free this pointer after usage.
View& operator= |
( |
const View< A > & |
view | ) |
|
Creates view which references to other View structure.
- Note
- This function is not create copy of image view! It only create a reference to the same image.
- Parameters
-
[in] | view | - an original image view. |
- Returns
- a reference to itself.
SIMD_INLINE View< A > & operator= |
( |
const cv::Mat & |
mat | ) |
|
Creates view which references to an OpenCV Mat.
- Note
- You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
- Parameters
-
- Returns
- a reference to itself.
SIMD_INLINE View< A > & Ref |
( |
| ) |
|
Creates reference to itself.
- Returns
- a reference to itself.
Re-creates a View structure with specified width, height, pixel format, pointer to pixel data and memory alignment.
- Parameters
-
[in] | w | - a width of re-created image view. |
[in] | h | - a height of re-created image view. |
[in] | f | - a pixel format of re-created image view. |
[in] | d | - a pointer to the external buffer with pixel data. If this pointer is NULL then will be created own buffer. |
[in] | align | - a required memory alignment. Its default value is determined by function Allocator::Alignment. |
SIMD_INLINE void Recreate |
( |
const Point< ptrdiff_t > & |
size, |
|
|
Format |
f |
|
) |
| |
Re-creates a View structure with specified width, height and pixel format.
- Parameters
-
[in] | size | - a size (width and height) of re-created image view. |
[in] | f | - a pixel format of re-created image view. |
SIMD_INLINE View< A > Region |
( |
ptrdiff_t |
left, |
|
|
ptrdiff_t |
top, |
|
|
ptrdiff_t |
right, |
|
|
ptrdiff_t |
bottom |
|
) |
| const |
Creates a new View structure which points to the region of current image bounded by the rectangle with specified coordinates.
- Parameters
-
[in] | left | - a left side of the region. |
[in] | top | - a top side of the region. |
[in] | right | - a right side of the region. |
[in] | bottom | - a bottom side of the region. |
- Returns
- - a new View structure which points to the region of current image.
SIMD_INLINE View< A > Region |
( |
const Point< ptrdiff_t > & |
topLeft, |
|
|
const Point< ptrdiff_t > & |
bottomRight |
|
) |
| const |
Creates a new View structure which points to the region of current image bounded by the rectangle with specified coordinates.
- Parameters
-
[in] | topLeft | - a top-left corner of the region. |
[in] | bottomRight | - a bottom-right corner of the region. |
- Returns
- - a new View structure which points to the region of current image.
SIMD_INLINE View< A > Region |
( |
const Rectangle< ptrdiff_t > & |
rect | ) |
const |
Creates a new View structure which points to the region of current image bounded by the rectangle with specified coordinates.
- Parameters
-
[in] | rect | - a rectangle which bound the region. |
- Returns
- - a new View structure which points to the region of current image.
SIMD_INLINE View< A > Region |
( |
const Point< ptrdiff_t > & |
size, |
|
|
Position |
position |
|
) |
| const |
Creates a new View structure which points to the region of current image bounded by the rectangle with specified coordinates.
- Parameters
-
[in] | size | - a size (width and height) of the region. |
[in] | position | - a value represents the position of the region (see Simd::View::Position). |
- Returns
- - a new View structure which points to the region of current image.
SIMD_INLINE View< A > Flipped |
( |
| ) |
const |
Creates a new View structure which points to the vertically flipped image.
- Returns
- - a new View structure which points to the flipped image.
SIMD_INLINE Point< ptrdiff_t > Size |
( |
| ) |
const |
Gets size (width and height) of the image.
- Returns
- - a new Point structure with image width and height.
SIMD_INLINE size_t DataSize |
( |
| ) |
const |
Gets size in bytes required to store pixel data of current View structure.
- Returns
- - a size of data pixels in bytes.
SIMD_INLINE size_t Area |
( |
| ) |
const |
Gets area in pixels of of current View structure.
- Returns
- - a area of current View in pixels.
const T& At |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| const |
Gets constant reference to the pixel of arbitrary type into current view with specified coordinates.
- Parameters
-
[in] | x | - a x-coordinate of the pixel. |
[in] | y | - a y-coordinate of the pixel. |
- Returns
- - a const reference to pixel of arbitrary type.
T& At |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
Gets reference to the pixel of arbitrary type into current view with specified coordinates.
- Parameters
-
[in] | x | - a x-coordinate of the pixel. |
[in] | y | - a y-coordinate of the pixel. |
- Returns
- - a reference to pixel of arbitrary type.
const T& At |
( |
const Point< ptrdiff_t > & |
p | ) |
const |
Gets constant reference to the pixel of arbitrary type into current view with specified coordinates.
- Parameters
-
[in] | p | - a point with coordinates of the pixel. |
- Returns
- - a const reference to pixel of arbitrary type.
T& At |
( |
const Point< ptrdiff_t > & |
p | ) |
|
Gets reference to the pixel of arbitrary type into current view with specified coordinates.
- Parameters
-
[in] | p | - a point with coordinates of the pixel. |
- Returns
- - a reference to pixel of arbitrary type.
SIMD_INLINE size_t PixelSize |
( |
Format |
format | ) |
|
|
static |
Gets pixel size in bytes for current pixel format.
- Parameters
-
[in] | format | - a pixel format. |
- Returns
- - a pixel size in bytes.
SIMD_INLINE size_t PixelSize |
( |
| ) |
const |
Gets pixel size in bytes for current image.
- Returns
- - a pixel size in bytes.
SIMD_INLINE size_t ChannelSize |
( |
Format |
format | ) |
|
|
static |
Gets pixel channel size in bytes for current pixel format.
- Parameters
-
[in] | format | - a pixel format. |
- Returns
- - a pixel channel size in bytes.
SIMD_INLINE size_t ChannelSize |
( |
| ) |
const |
Gets pixel channel size in bytes for current image.
- Returns
- - a pixel channel size in bytes.
SIMD_INLINE size_t ChannelCount |
( |
Format |
format | ) |
|
|
static |
Gets number of channels in the pixel for current pixel format.
- Parameters
-
[in] | format | - a pixel format. |
- Returns
- - a number of channels.
SIMD_INLINE size_t ChannelCount |
( |
| ) |
const |
Gets number of channels in the pixel for current image.
- Returns
- - a number of channels.
SIMD_INLINE int ToOcv |
( |
Format |
format | ) |
|
|
static |
Converts Simd Library pixel format to OpenCV Matrix type.
- Note
- You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
- Parameters
-
[in] | format | - a Simd Library pixel format. |
- Returns
- - an OpenCV Matrix type.
Converts OpenCV Matrix type to Simd Library pixel format.
- Note
- You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
- Parameters
-
[in] | type | - an OpenCV Matrix type. |
- Returns
- - a Simd Library pixel format.
SIMD_INLINE void Swap |
( |
View< A > & |
other | ) |
|
Swaps content of two (this and other) View structures.
- Parameters
-
[in] | other | - an other image view. |
SIMD_INLINE bool Load |
( |
const std::string & |
path | ) |
|
Loads 8-bit gray image from PGM(Portable Graymap Format) binary(P5) file.
- Note
- PGM files with comments are not supported.
- Parameters
-
[in] | path | - a path to file with PGM image. |
- Returns
- - a result of loading.
SIMD_INLINE bool Save |
( |
const std::string & |
path | ) |
const |
Saves 8-bit gray image to PGM(Portable Graymap Format) binary(P5) file.
- Parameters
-
[in] | path | - a path to file with PGM image. |
- Returns
- - a result of saving.
|