OpenJPH
Open-source implementation of JPEG2000 Part-15
ojph::param_nlt Class Reference

non-linearity point transformation object (implements NLT marker segment) More...

#include <ojph_params.h>

Public Types

enum  special_comp_num : ui16 { ALL_COMPS = 65535 }
 
enum  nonlinearity : ui8 {
  OJPH_NLT_NO_NLT = 0 , OJPH_NLT_GAMMA_STYLE_NLT = 1 , OJPH_NLT_LUT_STYLE_NLT = 2 , OJPH_NLT_BINARY_COMPLEMENT_NLT = 3 ,
  OJPH_NLT_UNDEFINED = 255
}
 

Public Member Functions

 param_nlt (local::param_nlt *p)
 
void set_nonlinear_transform (ui32 comp_num, ui8 nl_type)
 enables or disables type 3 nonlinearity for a component or the default setting More...
 
bool get_nonlinear_transform (ui32 comp_num, ui8 &bit_depth, bool &is_signed, ui8 &nl_type) const
 get the nonlinearity type associated with comp_num, which should be one from enum nonlinearity More...
 

Private Attributes

local::param_nltstate
 

Detailed Description

non-linearity point transformation object (implements NLT marker segment)

There are a few things to know here.
The NLT marker segment contains the nonlinearity type and the bit depth and signedness of the component to which it applies. There is the default component ALL_COMPS which applies to all components unless it is overridden by another NLT segment marker. The library checks that the settings make sense, and also make sure that bit depth and signedness are correct, creating any missing NLT marker segments in the process. If all components have the same bit depth and signedness, and need nonlinearity type 3 (Binary Complement to Sign Magnitude Conversion), then the best option is to set ALL_COMPS to type 3. Otherwise, the best option is to set type 3 only to components that need it, leaving out the default ALL_COMPS nonlinearity not set. Another option is for the end-user can set the ALL_COMPS to type 3, and then put exception for the components that does not need type 3, by setting them to type 0.

The library, during validity check, which is run when the codestream is created for writing, will do the following: – If ALL_COMPS is set to type 0, it will be ignored, and the codestream will NOT have the corresponding NLT marker segment. – If ALL_COMPS is set to type 3, then the following will happen:

  • If all the components (except those with type 0 set for them) have the same bit depth and signedness, then the ALL_COMPS NLT marker segment will be respected and inserted into the codestream. Of course, components with NLT 0 will also have the corresponding NLT marker segment inserted.
  • If components, for which no NTL type 0 is specified, have differing bit depth or signedness, then the ALL_COMPS will be ignored, and NLT markers are inserted for each component that needs type 3. Components that have their component field larger than the number of components in the codestream are removed.

It also worth noting that type 3 nonlinearity has no effect on positive image samples. It is also not recommended for integer-valued types. It is only recommended for floating-point image samples, for which some of the samples are negative, where type 3 nonlinearity should be beneficial. This is because the encoding engine expects two-complement representation for negative values while floating point numbers have a sign bit followed by an exponent, which has a biased integer representation. The core idea is to make floating-point representation more compatible with integer representation.

Definition at line 244 of file ojph_params.h.

Member Enumeration Documentation

◆ nonlinearity

Enumerator
OJPH_NLT_NO_NLT 
OJPH_NLT_GAMMA_STYLE_NLT 
OJPH_NLT_LUT_STYLE_NLT 
OJPH_NLT_BINARY_COMPLEMENT_NLT 
OJPH_NLT_UNDEFINED 

Definition at line 248 of file ojph_params.h.

◆ special_comp_num

Enumerator
ALL_COMPS 

Definition at line 247 of file ojph_params.h.

Constructor & Destructor Documentation

◆ param_nlt()

ojph::param_nlt::param_nlt ( local::param_nlt p)
inline

Definition at line 257 of file ojph_params.h.

Member Function Documentation

◆ get_nonlinear_transform()

bool ojph::param_nlt::get_nonlinear_transform ( ui32  comp_num,
ui8 bit_depth,
bool &  is_signed,
ui8 nl_type 
) const

get the nonlinearity type associated with comp_num, which should be one from enum nonlinearity

Parameters
comp_numcomponent number, or 65535 for the default setting
bit_depthreturns the bit depth of the component/default
is_signedreturns true if the component/default is signed
typenonlinearity type
Returns
true if the nonlinearity for comp_num is set

Definition at line 444 of file ojph_params.cpp.

References ojph::local::param_nlt::get_nonlinear_transform(), and state.

◆ set_nonlinear_transform()

void ojph::param_nlt::set_nonlinear_transform ( ui32  comp_num,
ui8  nl_type 
)

enables or disables type 3 nonlinearity for a component or the default setting

When creating a codestream for writing, call this function before you call codestream::write_headers.

Parameters
comp_numcomponent number, or 65535 for the default setting
typedesired non-linearity from enum nonlinearity

Definition at line 438 of file ojph_params.cpp.

References ojph::local::param_nlt::set_nonlinear_transform(), and state.

Referenced by main().

Member Data Documentation

◆ state

local::param_nlt* ojph::param_nlt::state
private

Definition at line 286 of file ojph_params.h.

Referenced by get_nonlinear_transform(), and set_nonlinear_transform().


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