Rescale class This class is meant to apply the linear tranform 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 thoughout 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). More...
#include <gdcmRescaler.h>
Public Member Functions | |
Rescaler () | |
~Rescaler () | |
PixelFormat::ScalarType | ComputeInterceptSlopePixelType () |
PixelFormat | ComputePixelTypeFromMinMax () |
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) |
Rescale class This class is meant to apply the linear tranform 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 thoughout 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).
Example: Let say input is FLOAT64, and we want UINT16 as ouput, 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::Rescaler::Rescaler | ( | ) | [inline] |
gdcm::Rescaler::~Rescaler | ( | ) | [inline] |
PixelFormat::ScalarType gdcm::Rescaler::ComputeInterceptSlopePixelType | ( | ) |
Compute the Pixel Format of the output data Used for direct transformation
PixelFormat gdcm::Rescaler::ComputePixelTypeFromMinMax | ( | ) |
Compute the Pixel Format of the output data Used for inverse transformation
bool gdcm::Rescaler::InverseRescale | ( | char * | out, |
const char * | in, | ||
size_t | n | ||
) |
Inverse transform.
void gdcm::Rescaler::InverseRescaleFunctionIntoBestFit | ( | char * | out, |
const TIn * | in, | ||
size_t | n | ||
) | [protected] |
bool gdcm::Rescaler::Rescale | ( | char * | out, |
const char * | in, | ||
size_t | n | ||
) |
Direct transform.
void gdcm::Rescaler::RescaleFunctionIntoBestFit | ( | char * | out, |
const TIn * | in, | ||
size_t | n | ||
) | [protected] |
void gdcm::Rescaler::SetIntercept | ( | double | i ) | [inline] |
Set Intercept: used for both direct&inverse transformation.
void gdcm::Rescaler::SetMinMaxForPixelType | ( | double | min, |
double | max | ||
) | [inline] |
Set target interval for output data. A best match will be computed (if possible) Used for inverse transformation
void gdcm::Rescaler::SetPixelFormat | ( | PixelFormat const & | pf ) | [inline] |
Set Pixel Format of input data.
void gdcm::Rescaler::SetSlope | ( | double | s ) | [inline] |
Set Slope: user for both direct&inverse transformation.
void gdcm::Rescaler::SetTargetPixelType | ( | PixelFormat const & | targetst ) |
void gdcm::Rescaler::SetUseTargetPixelType | ( | bool | b ) |
Override default behavior of Rescale.