AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agxIO::PNGImageValueInterpreter Class Reference

#include <ImageValueInterpreter.h>

+ Inheritance diagram for agxIO::PNGImageValueInterpreter:

Public Member Functions

 PNGImageValueInterpreter ()
 Default constructor.
 
 PNGImageValueInterpreter (float minValue, float maxValue)
 Construct given minimum- and maximum value.
 
agxIO::Image * getImage () const
 
size_t getImageHeight () const
 
size_t getImageWidth () const
 
float getMaxValue () const
 
float getMinValue () const
 
float getValue (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads image at pixel (x,y) and returns value between given minimum and maximum.
 
float getValueA (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Alpha" channel at pixel (x,y) and returns value between given minimum and maximum.
 
float getValueB (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Blue" channel at pixel (x,y) and returns value between given minimum and maximum.
 
float getValueG (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Green" channel at pixel (x,y) and returns value between given minimum and maximum.
 
float getValueR (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads single "Red" channel at pixel (x,y) and returns value between given minimum and maximum.
 
agx::Vec3f getValueRGB (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads R, G, and B channels and returns Vec3f with result at pixel (x,y).
 
agx::Vec4f getValueRGBA (size_t x, size_t y, GetValueFunction func=linearValueFunction) const
 Reads R, G, B and A channels and returns Vec4f with result at pixel (x,y).
 
bool read (const std::string &filename)
 Read PNG image.
 
void setMaxValue (float maxValue)
 Set new maximum value for the accessors methods (i.e., channel value = 255 => maximum value).
 
void setMinValue (float minValue)
 Set new minimum value for the accessors methods (i.e., channel value = 0 => minimum value).
 
void setValueA (unsigned char val, size_t x, size_t y)
 Set current value to the "Alpha" channel.
 
void setValueB (unsigned char val, size_t x, size_t y)
 Set current value to the "Blue" channel.
 
void setValueG (unsigned char val, size_t x, size_t y)
 Set current value to the "Green" channel.
 
void setValueR (unsigned char val, size_t x, size_t y)
 Set current value to the "Red" channel.
 
bool valid () const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referenced & operator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Protected Member Functions

virtual ~PNGImageValueInterpreter ()
 Reference counted object.
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

agxIO::ImageRef m_image
 
float m_maxValue
 
float m_minValue
 
ReadValue01Function m_readFunction
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Definition at line 82 of file ImageValueInterpreter.h.

Constructor & Destructor Documentation

◆ PNGImageValueInterpreter() [1/2]

agxIO::PNGImageValueInterpreter::PNGImageValueInterpreter ( )

Default constructor.

Minimum value set to 0 and maximum value to 1.

◆ PNGImageValueInterpreter() [2/2]

agxIO::PNGImageValueInterpreter::PNGImageValueInterpreter ( float  minValue,
float  maxValue 
)

Construct given minimum- and maximum value.

Parameters
minValue- minimum value when image channel value is zero
maxValue- maximum value when image channel value is 255

◆ ~PNGImageValueInterpreter()

virtual agxIO::PNGImageValueInterpreter::~PNGImageValueInterpreter ( )
protectedvirtual

Reference counted object.

Protected destructor.

Member Function Documentation

◆ getImage()

agxIO::Image * agxIO::PNGImageValueInterpreter::getImage ( ) const
Returns
the PNG image if initialized

◆ getImageHeight()

size_t agxIO::PNGImageValueInterpreter::getImageHeight ( ) const
Returns
the height of the image (number of pixels)

◆ getImageWidth()

size_t agxIO::PNGImageValueInterpreter::getImageWidth ( ) const
Returns
the width of the image (number of pixels)

◆ getMaxValue()

float agxIO::PNGImageValueInterpreter::getMaxValue ( ) const
Returns
the maximum value used by the accessors methods (when channel value = 255)

◆ getMinValue()

float agxIO::PNGImageValueInterpreter::getMinValue ( ) const
Returns
the minimum value used by the accessors methods (when channel value = 0)

◆ getValue()

float agxIO::PNGImageValueInterpreter::getValue ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads image at pixel (x,y) and returns value between given minimum and maximum.

Alpha channel is ignored for any PNG with alpha (i.e., 2 or 4). For 3 and 4 channels the RGB channels are merged to a gray scale single value and passed to GetValueFunction func.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum

◆ getValueA()

float agxIO::PNGImageValueInterpreter::getValueA ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Alpha" channel at pixel (x,y) and returns value between given minimum and maximum.

The PNG has to have either two or four channels for the value to be valid. E.g., if three channels, value of G will be calculated (offset = numChannels - 1). Asserts if number of channels is 1 or 3, but make sure you have the correct number of channels when calling this method.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum

◆ getValueB()

float agxIO::PNGImageValueInterpreter::getValueB ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Blue" channel at pixel (x,y) and returns value between given minimum and maximum.

The PNG has to have at least three channels for valid calls to this method.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum

◆ getValueG()

float agxIO::PNGImageValueInterpreter::getValueG ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Green" channel at pixel (x,y) and returns value between given minimum and maximum.

If the PNG has two channels, the alpha channel will be used here (i.e., same result as calling getValueA).

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum

◆ getValueR()

float agxIO::PNGImageValueInterpreter::getValueR ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads single "Red" channel at pixel (x,y) and returns value between given minimum and maximum.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
value between given minimum and maximum

◆ getValueRGB()

agx::Vec3f agxIO::PNGImageValueInterpreter::getValueRGB ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads R, G, and B channels and returns Vec3f with result at pixel (x,y).

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
Vec3f with results

◆ getValueRGBA()

agx::Vec4f agxIO::PNGImageValueInterpreter::getValueRGBA ( size_t  x,
size_t  y,
GetValueFunction  func = linearValueFunction 
) const

Reads R, G, B and A channels and returns Vec4f with result at pixel (x,y).

I.e., the PNG has to have four channels for the values to be valid.

Parameters
x- pixel at column x
y- pixel at row y
func- function taking a value from 0 to 1 following a given mathematical function (e.g., linear, quadratic, cubic etc)
Returns
Vec4f with results

◆ read()

bool agxIO::PNGImageValueInterpreter::read ( const std::string &  filename)

Read PNG image.

Searches agx paths.

Returns
true if load was successful - otherwise false (file not found or unsupported PNG)

◆ setMaxValue()

void agxIO::PNGImageValueInterpreter::setMaxValue ( float  maxValue)

Set new maximum value for the accessors methods (i.e., channel value = 255 => maximum value).

Parameters
maxValue- maximum value

◆ setMinValue()

void agxIO::PNGImageValueInterpreter::setMinValue ( float  minValue)

Set new minimum value for the accessors methods (i.e., channel value = 0 => minimum value).

Parameters
minValue- minimum value

◆ setValueA()

void agxIO::PNGImageValueInterpreter::setValueA ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Alpha" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.

◆ setValueB()

void agxIO::PNGImageValueInterpreter::setValueB ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Blue" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.

◆ setValueG()

void agxIO::PNGImageValueInterpreter::setValueG ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Green" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.

◆ setValueR()

void agxIO::PNGImageValueInterpreter::setValueR ( unsigned char  val,
size_t  x,
size_t  y 
)

Set current value to the "Red" channel.

Note
This value isn't stored in the actual image on disc - it's only stored in a local data storage.

◆ valid()

bool agxIO::PNGImageValueInterpreter::valid ( ) const
Returns
true if the image is valid

Member Data Documentation

◆ m_image

agxIO::ImageRef agxIO::PNGImageValueInterpreter::m_image
protected

Definition at line 246 of file ImageValueInterpreter.h.

◆ m_maxValue

float agxIO::PNGImageValueInterpreter::m_maxValue
protected

Definition at line 248 of file ImageValueInterpreter.h.

◆ m_minValue

float agxIO::PNGImageValueInterpreter::m_minValue
protected

Definition at line 247 of file ImageValueInterpreter.h.

◆ m_readFunction

ReadValue01Function agxIO::PNGImageValueInterpreter::m_readFunction
protected

Definition at line 249 of file ImageValueInterpreter.h.


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