stromx  0.8.0
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
stromx::cvsupport::Image Class Reference

Image with support for reading and writing. More...

#include <Image.h>

Inheritance diagram for stromx::cvsupport::Image:
stromx::runtime::ImageWrapper stromx::runtime::Image stromx::runtime::Matrix stromx::runtime::Data stromx::runtime::DataInterface

Public Types

enum  Conversion { UNCHANGED, GRAYSCALE = 0x2, COLOR = 0x4, DEPTH_16 = 0x8 }
 
- Public Types inherited from stromx::runtime::Image
enum  PixelType {
  NONE, MONO_8, MONO_16, RGB_24,
  RGB_48, BGR_24, BGR_48, BAYERBG_8,
  BAYERBG_16, BAYERGB_8, BAYERGB_16
}
 
- Public Types inherited from stromx::runtime::Matrix
enum  ValueType {
  NONE, INT_8, UINT_8, INT_16,
  UINT_16, INT_32, UINT_32, FLOAT_32,
  FLOAT_64
}
 

Public Member Functions

 Image ()
 
 Image (const unsigned int width, const unsigned int height, const PixelType pixelType)
 
 Image (const std::string &filename)
 
 Image (const std::string &filename, const Conversion access)
 
 Image (const stromx::runtime::Image &image)
 
 Image (const stromx::cvsupport::Image &image)
 
 Image (const cv::Mat &cvImage)
 
 Image (const cv::Mat &cvImage, const PixelType pixelType)
 
 Image (const unsigned int size)
 
virtual const runtime::Versionversion () const
 
virtual const std::string & type () const
 
virtual const std::string & package () const
 
virtual Dataclone () const
 
virtual void serialize (runtime::OutputProvider &output) const
 
virtual void deserialize (runtime::InputProvider &input, const stromx::runtime::Version &version)
 
virtual void initializeImage (const unsigned int width, const unsigned int height, const unsigned int stride, uint8_t *data, const PixelType pixelType)
 
virtual void initializeMatrix (const unsigned int rows, const unsigned int cols, const unsigned int stride, uint8_t *data, const ValueType valueType)
 
void open (const std::string &filename)
 
void open (const std::string &filename, const Conversion access)
 
void save (const std::string &filename) const
 
- Public Member Functions inherited from stromx::runtime::ImageWrapper
 ImageWrapper (const unsigned int bufferSize, uint8_t *const buffer)
 
 ImageWrapper ()
 
virtual const VariantHandlevariant () const
 
virtual uint8_t * buffer ()
 
virtual unsigned int bufferSize () const
 
virtual unsigned int rows () const
 
virtual unsigned int cols () const
 
virtual uint8_t * data ()
 
virtual const uint8_t * data () const
 
virtual unsigned int stride () const
 
virtual ValueType valueType () const
 
virtual unsigned int valueSize () const
 
virtual unsigned int width () const
 
virtual unsigned int height () const
 
virtual PixelType pixelType () const
 
virtual void initializeImage (const unsigned int width, const unsigned int height, const unsigned int stride, uint8_t *data, const PixelType pixelType)
 
void resize (const unsigned int width, const unsigned int height, const PixelType pixelType)
 
void resize (const unsigned int size)
 
- Public Member Functions inherited from stromx::runtime::Image
virtual unsigned int pixelSize () const
 
virtual unsigned int numChannels () const
 
virtual unsigned int depth () const
 
- Public Member Functions inherited from stromx::runtime::Matrix
template<class T >
T & at (const unsigned row, const unsigned col)
 
template<class T >
const T & at (const unsigned int row, const unsigned col) const
 
template<class T >
const T value (const unsigned int row, const unsigned int col) const
 
- Public Member Functions inherited from stromx::runtime::DataInterface
bool isVariant (const VariantInterface &v) const
 

Static Public Member Functions

static void save (const std::string &filename, const runtime::Image &image)
 
- Static Public Member Functions inherited from stromx::runtime::Image
static unsigned int pixelSize (const PixelType pixelType)
 
static unsigned int numChannels (const PixelType pixelType)
 
static unsigned depth (const PixelType pixelType)
 
- Static Public Member Functions inherited from stromx::runtime::Matrix
static unsigned int valueSize (const ValueType valueType)
 

Friends

STROMX_CVSUPPORT_API cv::Mat getOpenCvMat (const runtime::Image &image)
 

Additional Inherited Members

- Protected Member Functions inherited from stromx::runtime::ImageWrapper
void setBuffer (uint8_t *const buffer, const unsigned int bufferSize)
 
- Static Protected Member Functions inherited from stromx::runtime::Image
static const runtime::VariantHandle dataVariantFromPixelType (const PixelType pixelType)
 
static Matrix::ValueType valueTypeFromPixelType (const PixelType pixelType)
 
- Static Protected Member Functions inherited from stromx::runtime::Matrix
static const runtime::VariantHandle dataVariantFromValueType (const ValueType valueType)
 

Detailed Description

Image with support for reading and writing.

Member Enumeration Documentation

§ Conversion

Conversion options when reading images.

Enumerator
UNCHANGED 

The image data is not converted.

GRAYSCALE 

The image data is converted to grayscale. I.e. the resulting image is always a single-channel image.

COLOR 

The image data is converted to color. I.e. the resulting image is always 3-channel image.

DEPTH_16 

The image data is converted to 16-bits per channel. I.e. the resulting image is always 16-bit or 48-bit image. If an 8-bit image is converted to 16-bit its pixel values are multiplied by 256.

Constructor & Destructor Documentation

§ Image() [1/9]

stromx::cvsupport::Image::Image ( )

Constructs an empty image. The image width and height is 0 and no data is associated with the image, i.e. data and buffer are 0. The pixel type is Image::NONE.

§ Image() [2/9]

stromx::cvsupport::Image::Image ( const unsigned int  width,
const unsigned int  height,
const PixelType  pixelType 
)
explicit

Constructs an image for the given values.

§ Image() [3/9]

stromx::cvsupport::Image::Image ( const std::string &  filename)
explicit

Allocates an image and reads its content from the image file filename.

§ Image() [4/9]

stromx::cvsupport::Image::Image ( const std::string &  filename,
const Conversion  access 
)
explicit

Allocates an image and reads its content from the image file filename. The image data is converted according to access.

§ Image() [5/9]

stromx::cvsupport::Image::Image ( const stromx::runtime::Image image)
explicit

Copy constructs an image from image.

§ Image() [6/9]

stromx::cvsupport::Image::Image ( const stromx::cvsupport::Image image)
explicit

Copy constructs an image from image.

§ Image() [7/9]

stromx::cvsupport::Image::Image ( const cv::Mat &  cvImage)
explicit

Creates an image from cvImage. The input image is not copied but a reference to it is held in the constructed image. Use this to convert an OpenCV matrix to an stromx::cvsupport::Image object.

§ Image() [8/9]

stromx::cvsupport::Image::Image ( const cv::Mat &  cvImage,
const PixelType  pixelType 
)
explicit

Creates an image from cvImage. The input image is not copied but a reference to it is held in the constructed image. Use this to convert an OpenCV matrix to an stromx::cvsupport::Image object. The pixel type of the resulting image is set to pixelType.

Exceptions
WrongArgumentIf the input pixelType can not be set, i.e. it would imply an incompatible pixel size in bytes.

§ Image() [9/9]

stromx::cvsupport::Image::Image ( const unsigned int  size)
explicit

Allocates an image with a buffer of a given size in bytes. The width of the image is size and its height is 1. Its pixel type is Image::NONE. The buffer size of the image is guaranteed to be at least size.

Member Function Documentation

§ clone()

runtime::Data * stromx::cvsupport::Image::clone ( ) const
virtual

Returns a copy of the data object, i.e. a object of the same type is allocated and the data of the original object is copied to the new object. A pointer to the new object is returned.

Implements stromx::runtime::DataInterface.

§ deserialize()

void stromx::cvsupport::Image::deserialize ( runtime::InputProvider in,
const stromx::runtime::Version version 
)
virtual

Deserializes a data object.

Parameters
outThe input which the data obtained from.
versionThe version of the data class which serialized the input.

Reimplemented from stromx::runtime::Data.

§ initializeImage()

void stromx::cvsupport::Image::initializeImage ( const unsigned int  width,
const unsigned int  height,
const unsigned int  stride,
uint8_t *  data,
const PixelType  pixelType 
)
virtual

Initializes the image to the given data. Note that this function does not change the image buffer but merely changes the description of the data contained in the image buffer.

Implements stromx::runtime::Image.

§ initializeMatrix()

void stromx::cvsupport::Image::initializeMatrix ( const unsigned int  rows,
const unsigned int  cols,
const unsigned int  stride,
uint8_t *  data,
const ValueType  valueType 
)
virtual

Initializes the matrix to the given data. Note that this function does not change the matrix buffer but merely changes the description of the data contained in the matrix buffer.

Reimplemented from stromx::runtime::ImageWrapper.

§ open() [1/2]

void stromx::cvsupport::Image::open ( const std::string &  filename)

Reads the image filename. The data of the current image is replaced by the data of the new image.

§ open() [2/2]

void stromx::cvsupport::Image::open ( const std::string &  filename,
const Conversion  access 
)

Reads the image filename. The data of the current image is replaced by the data of the new image. The read image data is converted according to access.

§ package()

virtual const std::string& stromx::cvsupport::Image::package ( ) const
inlinevirtual

Returns the package of the class of this data object.

Implements stromx::runtime::DataInterface.

§ save() [1/2]

void stromx::cvsupport::Image::save ( const std::string &  filename,
const runtime::Image image 
)
static

Saves the input image to filename. The file format is automatically determined from the file name.

§ save() [2/2]

void stromx::cvsupport::Image::save ( const std::string &  filename) const

Saves the image to the file filename. The file format is automatically determined from the file name.

§ serialize()

void stromx::cvsupport::Image::serialize ( runtime::OutputProvider out) const
virtual

Serializes this data object.

Parameters
outThe output which the data is sent to.

Reimplemented from stromx::runtime::Data.

§ type()

virtual const std::string& stromx::cvsupport::Image::type ( ) const
inlinevirtual

Returns the name of the class of this data object.

Implements stromx::runtime::DataInterface.

§ version()

virtual const runtime::Version& stromx::cvsupport::Image::version ( ) const
inlinevirtual

Returns the version of the class of this data object.

Implements stromx::runtime::DataInterface.

Friends And Related Function Documentation

§ getOpenCvMat

STROMX_CVSUPPORT_API cv::Mat getOpenCvMat ( const runtime::Image image)
friend

Returns an OpenCV matrix header for image.


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