Thea
|
A 2D image. More...
#include <Image.hpp>
Public Member Functions | |
fipImage const * | _getFreeImage () const |
[Internal use only] Get the wrapped FreeImage bitmap. More... | |
fipImage * | _getFreeImage () |
[Internal use only] Get the wrapped FreeImage bitmap. More... | |
void | _setType (Type type_) |
[Internal use only] Set the type of the image. More... | |
int8 | clear () |
Destroy all image data, resetting the image to an invalid state. More... | |
bool | convert (Type dst_type) |
Convert this image to a different format. More... | |
bool | convert (Type dst_type, Image &dst) const |
Convert an image from one format to another. More... | |
int | getBitsInChannel (int channel) const |
Get the number of bits assigned to a particular channel. More... | |
int | getBitsPerChannel () const |
Get the number of bits assigned to each channel. More... | |
int | getBitsPerPixel () const |
Get the number of bits assigned to each pixel. More... | |
void const * | getData () const |
Get a pointer to the image data. More... | |
void * | getData () |
Get a pointer to the image data. More... | |
int64 | getDepth () const |
Get the depth of the image in pixels. More... | |
int64 | getHeight () const |
Get the height of the image in pixels. More... | |
double | getNormalizedValue (void const *pixel, int channel) const |
Get the value of a channel of a particular pixel, normalized to the range [0, 1]. More... | |
int32 | getRowAlignment () const |
Get the byte alignment of a pixel row. More... | |
void const * | getScanLine (int64 row, int64 z=0) const |
Get a pointer to the beginning of a specified row of pixels, optionally for a specific depth slice. More... | |
void * | getScanLine (int64 row, int64 z=0) |
Get a pointer to the beginning of a specified row of pixels, optionally for a specific depth slice. More... | |
int64 | getScanWidth () const |
Get the number of bytes consumed by a row of pixels. More... | |
int32 | getType () const |
Get the type of the image pixels, corresponding to one of the values of the Type enum class. More... | |
int64 | getWidth () const |
Get the width of the image in pixels. More... | |
bool | hasByteAlignedChannels () const |
Check if all pixel channels are aligned to byte addresses. More... | |
bool | hasByteAlignedPixels () const |
Check if the image pixels start at byte addresses. More... | |
Image () | |
Construct an empty image with no initial data. More... | |
Image (Type type_, int64 width_, int64 height_, int64 depth_=1) | |
Construct an uninitialized image of the specified type and pixel dimensions, which must have valid non-zero values. More... | |
Image (BinaryInputStream &input, Codec const &codec=CodecAuto(), bool read_block_header=false) | |
Construct an image by deserializing it from an input stream. More... | |
Image (std::string const &path, Codec const &codec=CodecAuto()) | |
Construct an image by loading it from a file. More... | |
bool | invert () |
Invert the pixel values of the image. More... | |
bool | isComplex () const |
Check if the channels hold complex (as opposed to real) values. More... | |
bool | isFloatingPoint () const |
Check if the channels hold floating-point values (at any precision). More... | |
int8 | isValid () const |
Check if the image has been allocated non-zero memory space (hence has valid type and dimensions) or not. More... | |
void | load (std::string const &path, Codec const &codec=CodecAuto()) |
Load the image from an image file. More... | |
int | numChannels () const |
Get the number of channels per pixel. More... | |
virtual void | read (TextInputStream &input, Codec const &codec=CodecAuto()) |
Read the object from a text input stream. More... | |
void | read (BinaryInputStream &input, Codec const &codec=CodecAuto(), bool read_block_header=false) |
Read the object from a binary input stream. More... | |
bool | rescale (int64 new_width, int64 new_height, int64 new_depth=1, Filter filter=Filter::AUTO) |
Rescale the image to a new width and height. More... | |
int8 | resize (int64 type, int64 width_, int64 height_, int64 depth_=1) |
Resize the image, changing its type and dimensions. More... | |
void | save (std::string const &path, Codec const &codec=CodecAuto()) const |
Save the image to an image file. More... | |
virtual void | write (TextOutputStream &output, Codec const &codec=CodecAuto()) const |
Write the object to a text output stream. More... | |
void | write (BinaryOutputStream &output, Codec const &codec=CodecAuto(), bool write_block_header=false) const |
Write the object to a binary output stream. More... | |
~Image () | |
Destructor. More... | |
Static Public Member Functions | |
static TextInputStream::Settings const & | configReadSettings () |
Get the default settings for parsing configuration text files. More... | |
static TextOutputStream::Settings const & | configWriteSettings () |
Get the default settings for writing configuration text files. More... | |
Image | ( | BinaryInputStream & | input, |
Codec const & | codec = CodecAuto() , |
||
bool | read_block_header = false |
||
) |
fipImage const* _getFreeImage | ( | ) | const |
fipImage* _getFreeImage | ( | ) |
void _setType | ( | Type | type_ | ) |
|
virtual |
|
staticinherited |
Get the default settings for parsing configuration text files.
Definition at line 69 of file Serializable.hpp.
|
staticinherited |
Get the default settings for writing configuration text files.
Definition at line 76 of file Serializable.hpp.
bool convert | ( | Type | dst_type | ) |
int getBitsInChannel | ( | int | channel | ) | const |
Get the number of bits assigned to a particular channel.
For luminance images, the single channel is assumed to correspond to the enum value Channel::ALPHA. If the image doesn't contain the specific channel (e.g. luminance images don't have red, green or blue channels) a value of zero is returned.
int getBitsPerChannel | ( | ) | const |
int getBitsPerPixel | ( | ) | const |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
double getNormalizedValue | ( | void const * | pixel, |
int | channel | ||
) | const |
Get the value of a channel of a particular pixel, normalized to the range [0, 1].
The following caveats should be noted:
This is a relatively slow way to iterate over pixel values and is provided only for convenience.
This function does not support channels smaller than a byte (e.g. Type::LUMINANCE_1U), and returns a value of zero for such images.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
bool hasByteAlignedChannels | ( | ) | const |
bool hasByteAlignedPixels | ( | ) | const |
bool isComplex | ( | ) | const |
bool isFloatingPoint | ( | ) | const |
|
virtual |
Check if the image has been allocated non-zero memory space (hence has valid type and dimensions) or not.
An image created by the default constructor is invalid and must be further initialized using Image::read() or a similar function.
Implements IImage.
Load the image from an image file.
The file should not have a prefixed Codec::BlockHeader. An exception will be thrown if the image cannot be loaded.
int numChannels | ( | ) | const |
Get the number of channels per pixel.
For example: 1 for luminance, 3 for RGB, 4 for RGBA. A complex number corresponds to a single channel (not two). Returns -1 if the image is of unknown type.
This returns a cached value and is likely to be faster than calling the equivalent function in Image::Type.
|
virtualinherited |
Read the object from a text input stream.
Reimplemented in Pyramid3d, KMeans, Pyramid2d, HoughForest::Options, BagOfWords, KMeans::Options, and Pyramid1d.
Definition at line 61 of file Serializable.hpp.
|
virtual |
Read the object from a binary input stream.
input | The stream from which to read data. |
codec | The codec to use. If set to CodecAuto(), the codec will be autodetected (if possible) from the input. |
read_block_header | If true, a Codec::BlockHeader object containing information about the codec and size of the serialized block will be first read from the input, and used to aid codec detection etc. The implementation is free to ignore this directive, e.g. if the codec and input size can be detected through other means. This behavior must be synchronized with write(BinaryOutputStream &, Codec const &, bool): either both must omit block headers, or both must read/write them if directed to do so. |
Implements Serializable.
bool rescale | ( | int64 | new_width, |
int64 | new_height, | ||
int64 | new_depth = 1 , |
||
Filter | filter = Filter::AUTO |
||
) |
|
virtual |
Save the image to an image file.
The file will not have a prefixed Codec::BlockHeader. An exception will be thrown if the image cannot be saved.
|
virtualinherited |
Write the object to a text output stream.
Reimplemented in Pyramid3d, KMeans, Pyramid2d, HoughForest::Options, BagOfWords, KMeans::Options, and Pyramid1d.
Definition at line 65 of file Serializable.hpp.
|
virtual |
Write the object to a binary output stream.
output | The stream to which data will be written. |
codec | The codec to use. If set to CodecAuto(), an appropriate codec will be automatically selected. |
write_block_header | If true, a Codec::BlockHeader object containing information about the codec and size of the serialized block will be first written to the input. The implementation is free to ignore this directive, e.g. if the codec and input size are encoded through other means. This behavior must be synchronized with read(BinaryInputStream &, Codec const &, bool): either both must omit block headers, or both must read/write them if directed to do so. |
Implements Serializable.