![]() |
Maria GDK 5.0.0.737
Documentation of native code in develop branch
|
#include <StkImage.h>
Classes | |
struct | FmtStruct |
Public Types | |
enum | Format { UNDEF = 0 , RGB_16 , RGB_24 , RGBA_32 , RGBA_16 , MONO_8 , MONO_8s , MONO_16 , MONO_16s , MONO_32 , MONO_32s , RGBA_DXT1 , RGBA_DXT3 , RGBA_DXT5 , MONOA_16 , MONO_FLOAT_32 , RGB_FLOAT_96 , RGB_FLOAT_48 , RGBA_FLOAT_64 , ARGB_32 , BGRA_32 , NUM_FORMATS } |
Image internal formats. More... | |
Public Member Functions | |
Image () | |
Image (ImageIO &loader) | |
Image (const std::vector< uint8_t > &imageBuffer) | |
Image (std::string filename) | |
Image (const Image &c) | |
Image (int width, int height, Format fmt, const char *data=nullptr) | |
bool | isNull () const |
bool | isCompressed () const |
bool | load (ImageIO &loader) |
bool | load (std::string filename) |
bool | load (const std::vector< uint8_t > &imgBuffer) |
bool | save (ImageIO &saver) const |
bool | save (const std::string &filename) const |
virtual bool | transform (ImageTransform &trans) |
bool | transform (ImageTransform &trans, Image &dest) const |
bool | hasAlphaChannel () const |
bool | isFloat () const |
void | setAlpha (unsigned char r, unsigned char g, unsigned char b, unsigned char val) |
bool | convert (Format fmt, Image &dst) const |
bool | convert (Format fmt) |
void | compose (const Image &r, const Image &g, const Image &b) |
void | compose (const Image &r, const Image &g, const Image &b, const Image &a) |
void | decompose (Image &r, Image &g, Image &b) const |
void | decomposeHSV (Image &h, Image &s, Image &v) const |
void | decompose (Image &r, Image &g, Image &b, Image &a) const |
virtual bool | getSubImage (int startx, int starty, int width, int height, Image &dst) |
int * | histogram () const |
void | histogram (std::vector< int > &hist) const |
double * | histogramNorm () const |
void | histogramNorm (std::vector< double > &hist) const |
double * | CDF () const |
void | CDF (std::vector< double > &cdf) const |
virtual void | calcMemSize () |
int | getWidth () const |
Get image width in pixels. | |
int | getHeight () const |
Get image height in pixels. | |
int | getNumPixels () const |
int | getPixelSize () const |
Get number of bytes per pixel. | |
int | getDepth () const |
Get number of bits per pixel. | |
int | getBPP () const |
int | getMemSize () const |
Get total size of image in bytes. | |
Format | getFormat () const |
Get the image format. | |
int | getNumBands () const |
Get the number of bands (channels) in the image. | |
int | getNumLevels () const |
Get number of mipmap levels. | |
int | getNodataValue () const |
void | setNodataValue (int nodata) |
unsigned char * | getData () const |
virtual unsigned char * | getData (int level) const |
unsigned char * | getVal (int x, int y) const |
unsigned char * | getVal (int x, int y, int l) const |
unsigned char * | getVal (unsigned int idx) const |
Color4i | getPixel (int x, int y) const |
Color4i | getPixel (int x, int y, int l) const |
Color4d | getPixel4d (int x, int y) const |
Color4d | getPixel4d (int x, int y, int l) const |
Color4i | getPixel (int idx) const |
Color4d | getPixel4d (int idx) const |
double | getValue (int idx) const |
double | getValue (int x, int y) const |
bool | isNodata (double val) const |
bool | setPixel (int x, int y, const Color4i &color) |
bool | setPixel (int x, int y, int l, const Color4i &color) |
bool | setPixel4d (int x, int y, const Color4d &color) |
bool | setPixel4d (int x, int y, int l, const Color4d &color) |
bool | setPixel (int idx, const Color4i &color) |
bool | setPixel4d (int idx, const Color4d &color) |
bool | setValue (int x, int y, double val) |
bool | setValue (int idx, double val) |
void | setWidth (int width) |
void | setHeight (int height) |
void | setNumLevels (int num_levels) |
void | setFormat (Format format) |
void | setDataPtr (unsigned char *data) |
void | allocMem () |
bool | setMipmap (const Image &img, int l) |
bool | setMipmap (unsigned char *src, int memsize, int level) |
virtual void | clear () |
virtual void | copyHeader (const Image &src) |
virtual void | moveData (Image &img) |
const Image & | operator= (const Image &c) |
void | flipVertical () |
void | flipHorizontal () |
void | fill (double val) |
Fill image with the given elevation value. | |
void | fill (const STK::Color4d &val) |
Fill image with the given pixel value. | |
void | fill (const STK::Color4i &val) |
Fill image with the given pixel value. | |
Static Public Member Functions | |
static std::string | formatToString (Format f) |
static Format | stringToFormat (std::string s) |
static int | pixelSize (Format fmt) |
Protected Member Functions | |
bool | getPixel (void *val, Color4i &ret) const |
bool | setPixel (void *val, const Color4i &col) |
bool | getPixel4d (void *val, Color4d &ret) const |
bool | setPixel4d (void *val, const Color4d &col) |
void | copy (const Image &c) |
Color4d | convertToColor4d (const Color4i &c) const |
Color4i | convertToColor4i (const Color4d &c) const |
Static Protected Member Functions | |
static void | initFmtInfo () |
Protected Attributes | |
unsigned int | memsize_ |
int | width_ |
int | height_ |
int | num_levels_ |
int | npix_ |
unsigned char * | data_ |
Format | format_ |
int | nodata_ |
Static Protected Attributes | |
static FmtStruct | fmt_info_ [NUM_FORMATS] |
Image - 2D raster image.
enum STK::Image::Format |
Image internal formats.
Image::Image | ( | ) |
Default constructor. This constructor creates an empty image with UNDEF pixel format.
Image::Image | ( | ImageIO & | loader | ) |
Constructor. This constructor creates an image and loads it with data from the given ImageIO object.
Image::Image | ( | const std::vector< uint8_t > & | imageBuffer | ) |
Constructor. This constructor creates an image and creates it with data from imageBuffer.
STK::Image::Image | ( | std::string | filename | ) |
Constructor. This constructor creates an image and loads it with data from the given file name.
Image::Image | ( | const Image & | c | ) |
Copy constructor. This method initializes an image with a copy of the given image object.
Image::Image | ( | int | width, |
int | height, | ||
Image::Format | fmt, | ||
const char * | data = nullptr |
||
) |
Create image from raw data. This constructor creates an image object from a chunk of bytes. The data is copied from the given pointer.
|
inlinevirtual |
Calculate image size. This method calculates the image size in bytes based on the width and height of the image and bits per pixel based on the image format. This method is called each time any of these parameters are changed.
double * Image::CDF | ( | ) | const |
Create cumulative distribution function (obsolete). This method creates a cumulative distribution function (CDF) for the image, which is simply a one-dimensional vector where each element is that fraction of the pixels in the image with intensity values less than or equal to the number of the element where the index starts at zero, i.e:
where
The return value is an array which is ordered such that the 256 CDF values of channel 0 comes first, then the 256 levels of channel 1, and so forth.
void Image::CDF | ( | std::vector< double > & | cdf | ) | const |
Create cumulative distribution function. This method creates a cumulative distribution function (CDF) for the image, which is simply a one-dimensional vector where each element is that fraction of the pixels in the image with intensity values less than or equal to the number of the element where the index starts at zero, i.e:
where
The return value is an array which is ordered such that the 256 CDF values of channel 0 comes first, then the 256 levels of channel 1, and so forth.
|
virtual |
Clear image data. This method deletes the image data and resets all other parameters to zero or undefined.
Compose image channels. This method joins the given intensity channels into an RGB_24 image. This method assumes that all input bands are MONO_8 and that they have equal dimensions.
Compose image channels. This method joins the given intensity channels into an RGBA_32 image. This method assumes that all input bands are MONO_8 and that they have equal dimensions.
bool Image::convert | ( | Format | fmt | ) |
Convert image pixel format. This function converts the image pixel format of the current image to fmt
.
Convert image pixel format. This method converts the image to the given pixel format storing the output in the image dst
.
|
virtual |
Copy header info from another image. This method copies the header info from the image 'src', such as width, height format, etc.
Decompose image channels. This method decomposes the image into 3 or 4 mono images containing each of the red, green, blue, and possibly alpha channels of the original image.
Decompose image channels. This method decomposes the image into 3 or 4 mono images containing each of the red, green, blue, and possibly alpha channels of the original image.
Decompose image channels (HSV). This method decomposes the image into 3 mono images containing each of the hue, saturation, and value channels of the original image.
|
static |
Convert format type to a string.
|
inline |
Get pointer to pixel data. This method returns a pointer to the pixel data contained in the image. Note that the return value is a pointer to unsigned char
, so for 16-bits image formats it may be convenient to cast this to unsigned short
.
|
inlinevirtual |
Get pointer to mipmap level.
|
inline |
Get nodata value. This value is used for missing data for example in elevation data files. Default value is -32767
|
inline |
Get pixel object by index. This method returns a Color4i object with the pixel data at index idx
in the raster. See getVal(int) for an explanation ofthe pixel ordering. For mono images, all components of the returned pixel are equal.
XXX: This interface should be updated to fit the other pixel access functions...
|
inline |
Get Pixel object by coordinates. This method returns a Color4i object with the pixel data at location
XXX: This interface should be updated to fit the other pixel access functions...
|
virtual |
Get subimage. This method extracts the pixels from (startx, starty) with dimensions (height, width) and puts it in the image object given by 'dst'.
|
inline |
Get data by coordinates. This method returns a pointer to the pixel data located at coordinates
|
inline |
Get data by pixel index. This method returns a pointer to the pixel data located at index idx
in the raster. Note that the data is stored row-wise, so that index
|
inline |
Convenience function for elevation data.
|
inline |
Convenience function for elevation data.
|
inline |
Returns true if the pixel format has an alpha channel. Note that this does not include texture compression formats even though they also have alpha.
int * Image::histogram | ( | ) | const |
Create histogram (obsolete). This method returns the histograms of the image bands as an integer array of length 256*<number of bands>, with number of samples per intensity level per band.
The array is ordered such that the 256 histogram levels of channel 0 comes first, then the 256 levels of channel 1, and so forth.
void Image::histogram | ( | std::vector< int > & | hist | ) | const |
Create histogram. This method returns the histograms of the image bands as an integer array of length 256*<number of bands>, with number of samples per intensity level per band.
The array is ordered such that the 256 histogram levels of channel 0 comes first, then the 256 levels of channel 1, and so forth.
double * Image::histogramNorm | ( | ) | const |
Create normalized histogram (obsolete). This method returns a normalized histogram of the image. i.e each pixel count is divided by the total number of pixels, so that each element in the histogram is a value in the range [0.0, 1.0].
The array is ordered such that the 256 histogram levels of channel 0 comes first, then the 256 levels of channel 1, and so forth.
void Image::histogramNorm | ( | std::vector< double > & | hist | ) | const |
Create normalized histogram This method returns a normalized histogram of the image. i.e each pixel count is divided by the total number of pixels, so that each element in the histogram is a value in the range [0.0, 1.0].
The array is ordered such that the 256 histogram levels of channel 0 comes first, then the 256 levels of channel 1, and so forth.
|
inline |
Check if image is compressed. Returns true if the image contains compressed pixel data.
|
inline |
Returns true if the image contains floating point data.
bool Image::load | ( | const std::vector< uint8_t > & | imgBuffer | ) |
Load image. This method loads the image from the given buffer.
bool Image::load | ( | ImageIO & | loader | ) |
Load image. This method loads the image with data from the given ImageIO object. Any previous data in the image object is deleted.
bool STK::Image::load | ( | std::string | filename | ) |
Load image. This method loads the image from the given file name. A suitable ImageIO object is created from the filename suffix.
|
static |
Get pixel size from format. This static method returns the size in bytes of a pixel in the given pixel format.
bool Image::save | ( | ImageIO & | saver | ) | const |
Save image. This method stores the image on disk using the given ImageIO object.
void Image::setAlpha | ( | unsigned char | r, |
unsigned char | g, | ||
unsigned char | b, | ||
unsigned char | val | ||
) |
Set alpha value. With this method you may set an alpha value for all pixels with the given color. For example if you want to set all black pixels to be semi-transparent you would say:
Note that this method may change the pixel format of the image, if the current format does not contain an alpha channel. If the format is RGB_24 it is converted to RGBA_32 and if the format is RGB_16 it is converted to RGBA_16.
bool Image::setMipmap | ( | const Image & | img, |
int | l | ||
) |
Set mipmap level. Use this method to set data for mipmap level l
. If image has less mipmap levels than l
, the method fails and returns false.
|
inline |
Set nodata value. This value is used for missing data for example in elevation data files. Default value is -32767
|
inline |
|
inline |
|
inline |
Convenience function for elevation data.
|
inline |
Convenience function for elevation data.
|
static |
Convert format type to a string.
|
virtual |
Generalized image transform. This method performs the transform operation(s) defined by the given ImageTransform object on the current image.
bool Image::transform | ( | ImageTransform & | trans, |
Image & | dest | ||
) | const |
Generalized image transform. This method performs the transform operation(s) defined by the given ImageTransform and places the results in the dst
Image object.