GDCM: gdcm::Rescaler Class Reference

GDCM 3.2.6

Public Member Functions | Protected Member Functions | List of all members
gdcm::Rescaler Class Reference

Rescale class. More...

`#include <gdcmRescaler.h>`

## Public Member Functions
| Rescaler ()
| ~Rescaler ()=default
PixelFormat::ScalarType | ComputeInterceptSlopePixelType ()
PixelFormat | ComputePixelTypeFromMinMax ()
double | GetIntercept () const
double | GetSlope () const
bool | InverseRescale (char *out, const char *in, size_t n)
| Inverse transform.
bool | Rescale (char *out, const char *in, size_t n)
| Direct transform.
void | SetIntercept (double i)
| Set Intercept: used for both direct&inverse transformation.
void | SetMinMaxForPixelType (double min, double max)
void | SetPixelFormat (PixelFormat const &pf)
| Set Pixel Format of input data.
void | SetSlope (double s)
| Set Slope: user for both direct&inverse transformation.
void | SetTargetPixelType (PixelFormat const &targetst)
void | SetUseTargetPixelType (bool b)
| Override default behavior of Rescale.

## Protected Member Functions
template<typename TIn>
void | InverseRescaleFunctionIntoBestFit (char *out, const TIn *in, size_t n)
template<typename TIn>
void | RescaleFunctionIntoBestFit (char *out, const TIn *in, size_t n)

## Detailed Description

Rescale class.

This class is meant to apply the linear transform of Stored Pixel Value to Real World Value. This is mostly found in CT or PET dataset, where the value are stored using one type, but need to be converted to another scale using a linear transform. There are basically two cases: In CT: the linear transform is generally integer based. E.g. the Stored Pixel Type is unsigned short 12bits, but to get Hounsfield unit, one need to apply the linear transform:

So the best scalar to store the Real World Value will be 16 bits signed type.

In PET: the linear transform is generally floating point based. Since the dynamic range can be quite high, the Rescale Slope / Rescale Intercept can be changing throughout the Series. So it is important to read all linear transform and deduce the best Pixel Type only at the end (when all the images to be read have been parsed).

Warning
  Internally any time a floating point value is found either in the Rescale Slope or the Rescale Intercept it is assumed that the best matching output pixel type is FLOAT64 (in previous implementation it was FLOAT32). Because VR:DS is closer to a 64bits floating point type FLOAT64 is thus a best matching pixel type for the floating point transformation.

Example: Let say input is FLOAT64, and we want UINT16 as output, we would do:

Rescaler ir;
ir.SetIntercept( 0 );
ir.SetSlope( 5.6789 );
ir.SetPixelFormat( FLOAT64 );
ir.SetMinMaxForPixelType( ((PixelFormat)UINT16).GetMin(), ((PixelFormat)UINT16).GetMax() );
ir.InverseRescale(output,input,numberofbytes );
gdcm::PixelFormat
PixelFormat.
Definition gdcmPixelFormat.h:46
gdcm::Rescaler::Rescaler
Rescaler()
Definition gdcmRescaler.h:71
gdcm::Rescaler::SetSlope
void SetSlope(double s)
Set Slope: user for both direct&inverse transformation.
Definition gdcmRescaler.h:85
gdcm::Rescaler::InverseRescale
bool InverseRescale(char *out, const char *in, size_t n)
Inverse transform.
gdcm::Rescaler::SetMinMaxForPixelType
void SetMinMaxForPixelType(double min, double max)
gdcm::Rescaler::SetPixelFormat
void SetPixelFormat(PixelFormat const &pf)
Set Pixel Format of input data.
Definition gdcmRescaler.h:98
gdcm::Rescaler::SetIntercept
void SetIntercept(double i)
Set Intercept: used for both direct&inverse transformation.
Definition gdcmRescaler.h:81

Note
  handle floating point transformation back and forth to integer properly (no loss)

See also
  Unpacker12Bits

Examples
  RescaleImage.cs.

## Constructor & Destructor Documentation

## ◆ Rescaler()

gdcm::Rescaler::Rescaler | ( |  | ) |
| inline

## ◆ ~Rescaler()

gdcm::Rescaler::~Rescaler | ( |  | ) |
| default

## Member Function Documentation

## ◆ ComputeInterceptSlopePixelType()

PixelFormat::ScalarType gdcm::Rescaler::ComputeInterceptSlopePixelType | ( |  | ) |

Compute the Pixel Format of the output data Used for direct transformation

Examples
  RescaleImage.cs.

## ◆ ComputePixelTypeFromMinMax()

PixelFormat gdcm::Rescaler::ComputePixelTypeFromMinMax | ( |  | ) |

Compute the Pixel Format of the output data Used for inverse transformation

## ◆ GetIntercept()

double gdcm::Rescaler::GetIntercept | ( |  | ) | const
| inline

## ◆ GetSlope()

double gdcm::Rescaler::GetSlope | ( |  | ) | const
| inline

## ◆ InverseRescale()

bool gdcm::Rescaler::InverseRescale | ( | char * | out,
|  | const char * | in,
|  | size_t | n )

Inverse transform.

## ◆ InverseRescaleFunctionIntoBestFit()

template<typename TIn>

void gdcm::Rescaler::InverseRescaleFunctionIntoBestFit | ( | char * | out,
|  | const TIn * | in,
|  | size_t | n )
| protected

## ◆ Rescale()

bool gdcm::Rescaler::Rescale | ( | char * | out,
|  | const char * | in,
|  | size_t | n )

Direct transform.

Examples
  RescaleImage.cs.

## ◆ RescaleFunctionIntoBestFit()

template<typename TIn>

void gdcm::Rescaler::RescaleFunctionIntoBestFit | ( | char * | out,
|  | const TIn * | in,
|  | size_t | n )
| protected

## ◆ SetIntercept()

void gdcm::Rescaler::SetIntercept | ( | double | i | ) |
| inline

Set Intercept: used for both direct&inverse transformation.

Examples
  RescaleImage.cs.

## ◆ SetMinMaxForPixelType()

void gdcm::Rescaler::SetMinMaxForPixelType | ( | double | min,
|  | double | max )

Set target interval for output data. A best match will be computed (if possible) Used for inverse transformation

## ◆ SetPixelFormat()

void gdcm::Rescaler::SetPixelFormat | ( | PixelFormat const & | pf | ) |
| inline

Set Pixel Format of input data.

Examples
  RescaleImage.cs.

## ◆ SetSlope()

void gdcm::Rescaler::SetSlope | ( | double | s | ) |
| inline

Set Slope: user for both direct&inverse transformation.

Examples
  RescaleImage.cs.

## ◆ SetTargetPixelType()

void gdcm::Rescaler::SetTargetPixelType | ( | PixelFormat const & | targetst | ) |

By default (when UseTargetPixelType is false), a best matching Target Pixel Type is computed. However user can override this auto selection by switching UseTargetPixelType:true and also specifying the specific Target Pixel Type

## ◆ SetUseTargetPixelType()

void gdcm::Rescaler::SetUseTargetPixelType | ( | bool | b | ) |

Override default behavior of Rescale.

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

- gdcmRescaler.h