PCL
|
Normalization data parser and generator. More...
#include <LocalNormalizationData.h>
Public Types | |
using | matrix_interpolation = BicubicBSplineInterpolation< normalization_coefficient > |
using | matrix_interpolations = Array< matrix_interpolation > |
using | normalization_coefficient = normalization_matrices::sample |
using | normalization_matrices = Image |
Public Member Functions | |
LocalNormalizationData ()=default | |
LocalNormalizationData (const LocalNormalizationData &)=default | |
LocalNormalizationData (const String &filePath, bool ignoreNormalizationData=false) | |
LocalNormalizationData (const XMLDocument &xml, bool ignoreNormalizationData=false) | |
LocalNormalizationData (const XMLElement &element, bool ignoreNormalizationData=false) | |
LocalNormalizationData (LocalNormalizationData &&)=default | |
virtual | ~LocalNormalizationData () |
const Vector & | Bias () const |
void | Clear () |
TimePoint | CreationTime () const |
void | DisableCompression (bool disable=true) |
void | EnableCompression (bool enable=true) |
const Vector & | GlobalReferenceLocation () const |
const Vector & | GlobalScalingFactors () const |
const Vector & | GlobalTargetLocation () const |
bool | HasInterpolations () const |
void | InitInterpolations () |
bool | IsCompressionEnabled () const |
bool | IsTaggedAsInvalid () const |
int | NormalizationScale () const |
int | NumberOfChannels () const |
double | operator() (double z, int x, int y, int c=0) const |
void | Parse (const String &filePath, bool ignoreNormalizationData=false) |
void | Parse (const XMLDocument &xml, bool ignoreNormalizationData=false) |
void | Parse (const XMLElement &element, bool ignoreNormalizationData=false) |
const String & | ReferenceFilePath () const |
int | ReferenceHeight () const |
int | ReferenceWidth () const |
const Vector & | RelativeScaleFactors () const |
const normalization_matrices & | Scale () const |
XMLDocument * | Serialize () const |
void | SerializeToFile (const String &path) const |
void | SetGlobalNormalizationParameters (const Vector &Rc, const Vector &Tc, const Vector &S) |
void | SetLocalNormalizationParameters (const normalization_matrices &A, const normalization_matrices &B, const Vector &C=Vector()) |
void | SetNormalizationScale (int scale) |
void | SetReferenceDimensions (int width, int height) |
void | SetReferenceFilePath (const String &filePath) |
void | SetRelativeScaleFactors (const Vector &s) |
void | SetTargetFilePath (const String &filePath) |
void | SetVersion (int version) |
void | TagAsInvalid () |
const String & | TargetFilePath () const |
int | Version () const |
const normalization_matrices & | ZeroOffset () const |
LocalNormalizationData implements support for the XML normalization data format (XNML format, .xnml file suffix).
An XNML file stores local normalization function data suitable for pixel rejection and image integration tasks, including drizzle integration. The LocalNormalizationData class is a high-level interface for parsing and generation of these special files.
Local normalization functions are serialized as floating point real images, where each channel stores scaling and zero offset coefficients, sampled at a prescribed normalization scale, for a channel of a specific image.
For a channel index c and position vector i on a given input image, the local normalization function is:
v'(c,i) = U(A(c,i))*(v(c,i) - C(c)) + U(B(c,i))
where A(c) is the matrix of scaling coefficients, B(c) is the matrix of zero offset coefficients, C(c) is the bias level (C = 0 by default), U() is a scale-dependent interpolation functional, v is an input pixel value, and v' is the normalized pixel value.
This implementation can also apply an optional global normalization function after the local normalization. If the corresponding parameters are defined, the global normalization function is:
v''(c,i) = S(c)*(v'(c,i) - T(c)) + R(c)
where S is a vector of global scaling factors, T is a vector of target locations, and R is a vector of reference locations. v' is the locally normalized pixel value, as defined above, and v'' is the output value after local and global normalization.
Local normalization matrices are conveniently stored as multichannel, two-dimensional images, which facilitates two-dimensional interpolation with smooth pixel interpolation algorithms. Normalization matrices are normally much smaller than the reference image dimensions. This happens because we define local normalization functions at a specific dimensional scale, which typically corresponds to a large dyadic scale of 64, 128, or 256 pixels. For this reason, normalization matrices require a smooth interpolation to compute normalization coefficients at reference image coordinates.
Definition at line 120 of file LocalNormalizationData.h.
using pcl::LocalNormalizationData::matrix_interpolation = BicubicBSplineInterpolation<normalization_coefficient> |
Represents a smooth interpolation used for calculation of local normalization function values at image pixel coordinates.
Definition at line 138 of file LocalNormalizationData.h.
Represents an array of local normalization interpolators.
Definition at line 143 of file LocalNormalizationData.h.
Represents a local normalization function coefficient.
Definition at line 132 of file LocalNormalizationData.h.
Represents a per-channel set of local image normalization matrices.
Definition at line 127 of file LocalNormalizationData.h.
|
default |
Constructs an empty LocalNormalizationData object.
|
default |
Copy constructor.
|
default |
Move constructor.
|
inline |
Constructs a new LocalNormalizationData instance by loading and parsing a file in XNML format.
filePath | Path to an existing file that will be parsed. The file contents must be in XML normalization data format (usually, a file with the .xnml suffix). |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
This constructor validates the data retrieved from the specified file. It throws the appropriate Error exceptions in the event of parsing errors or invalid data.
Definition at line 179 of file LocalNormalizationData.h.
|
inline |
Constructs a new LocalNormalizationData instance by parsing a well-formed XML document in XNML format.
xml | Reference to the source XML document. This constructor expects an XML document in valid XML normalization data format (.xnml). |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
This constructor validates the data retrieved from the specified XML document. It throws an Error exception in the event of an invalid document or invalid data.
Definition at line 203 of file LocalNormalizationData.h.
|
inline |
Constructs a new LocalNormalizationData instance by parsing an XML element in XNML format.
element | Reference to the source XML element. This constructor expects an XML document tree in valid XML normalization data format (.xnml) rooted at the specified element. |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
This constructor validates the data retrieved from the specified XML element. It throws an Error exception in the event of invalid data.
Definition at line 227 of file LocalNormalizationData.h.
|
inlinevirtual |
Virtual destructor.
Definition at line 235 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the vector of per-channel bias levels. Each bias is a constant scalar subtracted from input pixel sample values before applying the local normalization function. This allows to remove any systematic offset or additive pedestal that could be present in the data to be normalized. The possibility to remove a constant value also adds flexibility to the local normalization function.
If not specified, the target bias is always zero by default.
Definition at line 398 of file LocalNormalizationData.h.
void pcl::LocalNormalizationData::Clear | ( | ) |
Clears all of the image normalization data transported by this instance, yielding an empty LocalNormalizationData object.
|
inline |
Returns the UTC time this normalization data was created, or an invalid TimePoint instance if creation time information is not available.
Definition at line 600 of file LocalNormalizationData.h.
|
inline |
Disables compression of serialized local normalization data.
Definition at line 709 of file LocalNormalizationData.h.
|
inline |
Enables compression of serialized local normalization data.
Definition at line 699 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the vector of per-channel global reference locations (or zero-offsets).
Definition at line 447 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the vector of per-channel global scaling factors.
Definition at line 470 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the vector of per-channel global target locations (or zero-offsets).
Definition at line 459 of file LocalNormalizationData.h.
|
inline |
Returns true iff valid local normalization function data have been loaded and the internal interpolators have been initialized.
Definition at line 559 of file LocalNormalizationData.h.
void pcl::LocalNormalizationData::InitInterpolations | ( | ) |
Initializes the internal local normalization function interpolators. After this initialization, operator()() can be called repeatedly to apply the local normalization function to pixel sample values in reference image coordinates.
Calling this member function is not necessary when valid local normalization data have been loaded from an XNML file or XML document, since in this case the internal interpolators are always initialized automatically. This function must be called, however, for newly defined normalization data set by calling SetReferenceDimensions() and SetLocalNormalizationParameters().
If this object has not been initialized with valid local normalization data, this member function throws an Error exception.
|
inline |
Returns true if data compression is enabled for serializations performed with this object.
Data compression is enabled by default for newly constructed LocalNormalizationData objects. Currently the LZ4 compression codec is applied for serialization of local normalization matrices.
Definition at line 689 of file LocalNormalizationData.h.
|
inline |
Returns true iff this object has parsed XNML source code, either from an existing file or from an XML document or element, that has been tagged as invalid local normalization data.
Definition at line 747 of file LocalNormalizationData.h.
|
inline |
Returns the scale in pixels at which the local normalization functions were sampled and calculated. For valid normalization data, the returned value must be larger than zero, and should normally be larger than or equal to 32 pixels.
Definition at line 300 of file LocalNormalizationData.h.
|
inline |
Returns the number of channels or pixel sample planes in the image represented by this instance, or zero if this object has not been initialized with valid data.
Definition at line 355 of file LocalNormalizationData.h.
|
inline |
Returns a locally normalized pixel sample value.
z | Input pixel sample value (unnormalized). |
x | Horizontal image pixel coordinate. |
y | Vertical image pixel coordinate. |
c | Channel index. |
This operator interpolates local normalization functions and applies the corresponding linear transformation to the input value z, which gives the return value. Note that the normalized value might be out of the input pixel sample range. In such case the normalized value should be truncated or rescaled as appropriate.
For performance reasons, this operator does not check that the required normalization and interpolation data have been initialized; if they are not, calling this operator will most likely lead to a crash. Interpolation data are automatically initialized when a valid XNML file or XML element is loaded and parsed. For newly constructed objects, make sure you define the required reference dimensions and normalization matrices. Then call InitInterpolations() before starting to call this operator.
Definition at line 587 of file LocalNormalizationData.h.
void pcl::LocalNormalizationData::Parse | ( | const String & | filePath, |
bool | ignoreNormalizationData = false |
||
) |
Loads and parses a normalization data file in XNML format.
filePath | Path to an existing file that will be parsed. The file contents must be in XML normalization data format (usually, a file with the .xnml suffix). |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
All of the previous data transported by this instance will be replaced with new data acquired from the specified file.
This function validates the data retrieved from the specified file. It throws an Error exception in the event of parsing errors or invalid data.
void pcl::LocalNormalizationData::Parse | ( | const XMLDocument & | xml, |
bool | ignoreNormalizationData = false |
||
) |
Parses a well-formed XML document in XNML format.
xml | Reference to the source XML document. This member function expects an XML document in valid XML normalization data format (.xnml). |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
All of the previous data transported by this instance will be replaced with new data acquired from the specified XML contents.
This function validates the data retrieved from the specified XML document. It throws an Error exception in the event of an invalid document or invalid data.
void pcl::LocalNormalizationData::Parse | ( | const XMLElement & | element, |
bool | ignoreNormalizationData = false |
||
) |
Parses an XML element in XNML format.
element | Reference to the source XML element. This member function expects an XML document tree in valid XML normalization data format (.xnml) rooted at the specified element. |
ignoreNormalizationData | If true, local normalization data will be ignored and not parsed. This includes matrices of normalization function coefficients. Setting this parameter to true can be useful when the caller only needs to retrieve information on file paths and reference dimensions. |
All of the previous data transported by this instance will be replaced with new data acquired from the specified XML contents.
This function validates the data retrieved from the specified XML element. It throws an Error exception in the event of invalid data.
|
inline |
Returns the full path to the reference image file used for calculation of the normalization data represented by this instance, or an empty string if that file path is not available.
Definition at line 246 of file LocalNormalizationData.h.
|
inline |
Returns the height in pixels of the normalization reference and target images, or -1 if this object has not been initialized with valid data.
Definition at line 333 of file LocalNormalizationData.h.
|
inline |
Returns the width in pixels of the normalization reference and target images, or -1 if this object has not been initialized with valid data.
Definition at line 322 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the vector of per-channel relative scale factors.
Definition at line 510 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the set of matrices of scaling coefficients in the local normalization function.
See the class description for detailed information on local normalization functions.
Definition at line 383 of file LocalNormalizationData.h.
XMLDocument* pcl::LocalNormalizationData::Serialize | ( | ) | const |
Serializes the normalization data transported by this object as a new XML document in XNML format.
The returned XMLDocument object has been allocated dynamically. The caller is responsible for destroying and deallocating it as appropriate.
void pcl::LocalNormalizationData::SerializeToFile | ( | const String & | path | ) | const |
Serializes the normalization data transported by this object as a new XML document file in XNML format (.xnml). The file will be newly created at the specified file path.
|
inline |
Sets new global normalization vectors.
Rc | Reference to a vector of per-channel reference global locations. |
Tc | Reference to a vector of per-channel target global locations. |
S | Reference to a vector of per-channel global scaling factors. |
See the class description for detailed information on local normalization functions.
This function throws an Error exception if some of the specified global normalization parameters are invalid or incongruent.
Definition at line 496 of file LocalNormalizationData.h.
|
inline |
Sets new local normalization function parameters.
A | Reference to an image storing the matrices of scaling normalization coefficients. |
B | Reference to an image storing the matrices of zero offset normalization coefficients. |
C | Reference to an optional vector of per-channel biases. If not specified, the bias will be set to zero for each channel by default. |
See the class description for detailed information on local normalization functions.
This function throws an Error exception if some of the specified local normalization parameters are invalid or incongruent.
Definition at line 424 of file LocalNormalizationData.h.
|
inline |
Sets the scale in pixels at which the local normalization functions have been sampled and calculated.
Definition at line 311 of file LocalNormalizationData.h.
|
inline |
Sets new normalization image dimensions in pixels, width and height, respectively.
Definition at line 344 of file LocalNormalizationData.h.
|
inline |
Sets the path to the reference image file used for calculation of the normalization data stored in this instance.
Definition at line 257 of file LocalNormalizationData.h.
References pcl::File::FullPath().
|
inline |
Sets a new relative scale factors vector.
Rc | Reference to a vector of per-channel relative scale factors. |
See the class description for detailed information on local normalization functions.
This function throws an Error exception if the specified vector is invalid or incongruent with normalization data.
Definition at line 526 of file LocalNormalizationData.h.
|
inline |
Sets the path to the image file for which the normalization data stored in this instance was calculated.
Definition at line 287 of file LocalNormalizationData.h.
References pcl::File::FullPath().
|
inline |
Sets the normalization data version. See Version() for information on normalization data versions.
Definition at line 737 of file LocalNormalizationData.h.
|
inline |
Tags this object as invalid local normalization data.
Definition at line 755 of file LocalNormalizationData.h.
|
inline |
Returns the full path to the image file for which the normalization data represented by this instance was calculated, or an empty string if such file path is not available.
The file identified by this function stores the input image of the image normalization task that created this object. This file can be used as input for a regular (non-drizzle) integration task, and the data transported by this object can then be used for normalization of pixel values in pixel rejection and/or integration output generation, including drizzle integration.
Definition at line 276 of file LocalNormalizationData.h.
|
inline |
Returns a version number corresponding to the normalization data transported by this object.
Version numbers can be used to control the use and propagation of normalization data generated by different versions of a normalization tool or process, such as the standard LocalNormalization process in PixInsight. The version number is zero by default, meaning that the version is unspecified. An appropriate version number > 0 can be set by calling SetVersion(), which is recommended before serializing normalization data to a new XNML file. When an XNML file is loaded and it contains a valid version number tag, it is loaded and will be returned by this function. Otherwise the returned value will be zero.
Definition at line 728 of file LocalNormalizationData.h.
|
inline |
Returns a reference to the set of matrices of zero offset coefficients in the local normalization function.
See the class description for detailed information on local normalization functions.
Definition at line 369 of file LocalNormalizationData.h.