DCMTK  Version 3.6.6
OFFIS DICOM Toolkit
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
DicomImageComparison Class Reference

A helper class for comparing an original image with a processed version (e.g. More...

Public Member Functions

 DicomImageComparison ()
 default constructor
 
virtual ~DicomImageComparison ()
 destructor
 
OFCondition initializeDiffImage (OFCmdFloat amplify=1.0)
 instruct the DicomImageComparison instance that the creation of a difference image during image comparison is requested. More...
 
OFCondition saveDiffImage (const char *ofname)
 save the difference image created during image comparison. More...
 
OFCondition readReferenceImage (const char *ifname, E_TransferSyntax xfer, E_FileReadMode readMode, unsigned long compatibilityMode)
 read reference image for image comparison from file More...
 
OFCondition readTestImage (const char *ifname, E_TransferSyntax xfer, E_FileReadMode readMode, unsigned long compatibilityMode)
 read test image for image comparison from file More...
 
OFCondition configureImages (EW_WindowType windowType, OFBool sharedWindow, OFCmdUnsignedInt windowParameter, OFCmdFloat windowCenter, OFCmdFloat windowWidth, EF_VoiLutFunction voiFunction, ES_PresentationLut presShape)
 configure the display pipelines for both referenced and test image. More...
 
OFCondition computeImageComparisonMetrics (EW_WindowType windowType)
 compare both images and compute image comparion metrics. More...
 
unsigned long getMaxAbsoluteError () const
 return maximum absolute error
 
double getMeanAbsoluteError () const
 return mean absolute error
 
double getRootMeanSquareError () const
 return root mean square error
 
double getPeakSignalToNoiseRatio () const
 return peak signal to noise ratio
 
double getSignalToNoiseRatio () const
 return signal to noise ratio
 

Private Member Functions

 DicomImageComparison (const DicomImageComparison &rhs)
 private undefined copy constructor
 
DicomImageComparisonoperator= (const DicomImageComparison &arg)
 private undefined copy assignment operator
 
OFCondition checkImageCharacteristics () const
 check if reference and test image have the same resolution, number of frames and color model (color or monochrome). More...
 
OFCondition computeMonochromeImageComparionMetricsWord ()
 compare two images that are both monochrome and have more than 8 bits/pixel in internal storage, as determined by BitsStored and the Modality LUT that may have been applied. More...
 
OFCondition computeMonochromeImageComparionMetricsRaw ()
 compare two monochrome images without setting a VOI window. More...
 
OFCondition computeMonochromeImageComparionMetricsByte ()
 compare two images that are both monochrome and have at most 8 bits/pixel in internal storage, as determined by BitsStored and the Modality LUT that may have been applied. More...
 
OFCondition computeColorImageComparionMetrics ()
 compare two images that are both color images. More...
 

Static Private Member Functions

static OFCondition readDICOMImage (DicomImage *&di, OFBool isReference, const char *ifname, E_TransferSyntax xfer, E_FileReadMode readMode, unsigned long compatibilityMode, DcmItem *diffImage)
 read DICOM image and store pointer to it More...
 
static OFCondition configureImage (DicomImage *di, EW_WindowType windowType, OFCmdUnsignedInt windowParameter, OFCmdFloat &windowCenter, OFCmdFloat &windowWidth, EF_VoiLutFunction voiFunction, ES_PresentationLut presShape, int &depth)
 configure the display pipeline for a given DICOM image. More...
 
static OFCondition copyReferenceImageAttributes (DcmItem *src, DcmItem *diffImage)
 initialize the difference image DICOM dataset by copying all required attributes from the reference image and by generating all other attributes except for the image pixel module, SOP Class UID, and the information to be copied from the test image. More...
 
static OFCondition copyTestImageAttributes (DcmItem *src, DcmItem *diffImage)
 further populate the difference image DICOM dataset by copying all required attributes from the test image. More...
 
static void logImageInfo (DicomImage *di, const char *filename)
 print the characteristics of the image to to logger at DEBUG level. More...
 
static void createFrameLabelVector (OFString &s, unsigned long numFrames, OFBool isColor)
 create content for frame label vector More...
 

Private Attributes

DicomImagedi_reference
 pointer to reference image
 
DicomImagedi_test
 pointer to test image
 
DcmFileFormatdiff_image
 difference image in DICOM format
 
unsigned long max_error
 result of image comparison: max difference between a sample value in the reference image and the corresponding sample value in the test image
 
int reference_bits
 bits/sample to use when processing the reference image
 
int test_bits
 bits/sample to use when processing the test image
 
double meanAbsoluteError
 result of image comparison: mean absolute error
 
double rootMeanSquareError
 result of image comparison: root mean square error (RMSE)
 
double peakSignalToNoiseRatio
 result of image comparison: peak signal to noise ratio (PSNR)
 
double signalToNoiseRatio
 result of image comparison: signal to noise ratio (SNR)
 
double amplification
 factor by which all pixel values of the difference image will be multiplied
 

Detailed Description

A helper class for comparing an original image with a processed version (e.g.

after lossy compression).

Member Function Documentation

◆ checkImageCharacteristics()

OFCondition DicomImageComparison::checkImageCharacteristics ( ) const
private

check if reference and test image have the same resolution, number of frames and color model (color or monochrome).

Returns
EC_Normal if matching, an error code otherwise.

◆ computeColorImageComparionMetrics()

OFCondition DicomImageComparison::computeColorImageComparionMetrics ( )
private

compare two images that are both color images.

Returns
EC_Normal if successful, an error code otherwise.

◆ computeImageComparisonMetrics()

OFCondition DicomImageComparison::computeImageComparisonMetrics ( EW_WindowType  windowType)

compare both images and compute image comparion metrics.

Parameters
windowTypeVOI LUT transformation to apply
Returns
EC_Normal if successful, an error code otherwise.

◆ computeMonochromeImageComparionMetricsByte()

OFCondition DicomImageComparison::computeMonochromeImageComparionMetricsByte ( )
private

compare two images that are both monochrome and have at most 8 bits/pixel in internal storage, as determined by BitsStored and the Modality LUT that may have been applied.

Returns
EC_Normal if successful, an error code otherwise.

◆ computeMonochromeImageComparionMetricsRaw()

OFCondition DicomImageComparison::computeMonochromeImageComparionMetricsRaw ( )
private

compare two monochrome images without setting a VOI window.

Returns
EC_Normal if successful, an error code otherwise.

◆ computeMonochromeImageComparionMetricsWord()

OFCondition DicomImageComparison::computeMonochromeImageComparionMetricsWord ( )
private

compare two images that are both monochrome and have more than 8 bits/pixel in internal storage, as determined by BitsStored and the Modality LUT that may have been applied.

Returns
EC_Normal if successful, an error code otherwise.

◆ configureImage()

static OFCondition DicomImageComparison::configureImage ( DicomImage di,
EW_WindowType  windowType,
OFCmdUnsignedInt  windowParameter,
OFCmdFloat &  windowCenter,
OFCmdFloat &  windowWidth,
EF_VoiLutFunction  voiFunction,
ES_PresentationLut  presShape,
int &  depth 
)
staticprivate

configure the display pipeline for a given DICOM image.

Parameters
diDICOM image, must not be NULL
windowTypeVOI LUT transformation to apply
windowParameterindex of VOI LUT/window in file (if windowType is EWT_window_from_file or EWT_voi_lut_from_file)
windowCenterwindow center (input for EWT_window_parameters, output for EWT_window_min_max and EWT_window_min_max_n)
windowWidthwindow width (input for EWT_window_parameters, output for EWT_window_min_max and EWT_window_min_max_n)
voiFunctionVOI LUT function (linear or sigmoid)
presShapePresentation LUT Shape (identity, reverse, lin OD)
depthbit depth to be used when accessing pixel data for this image returned in this parameter
Returns
EC_Normal if successful, and error code otherwise

◆ configureImages()

OFCondition DicomImageComparison::configureImages ( EW_WindowType  windowType,
OFBool  sharedWindow,
OFCmdUnsignedInt  windowParameter,
OFCmdFloat  windowCenter,
OFCmdFloat  windowWidth,
EF_VoiLutFunction  voiFunction,
ES_PresentationLut  presShape 
)

configure the display pipelines for both referenced and test image.

Parameters
windowTypeVOI LUT transformation to apply
sharedWindowcompute common min/max window for both images if true, separate windows if false
windowParameterindex of VOI LUT/window in file (if windowType is EWT_window_from_file or EWT_voi_lut_from_file)
windowCenterwindow center (ignored unless windowType is EWT_window_parameters)
windowWidthwindow width (ignored unless windowType is EWT_window_parameters)
voiFunctionVOI LUT function (linear or sigmoid)
presShapePresentation LUT Shape (identity, reverse, lin OD)
Returns
EC_Normal if successful, and error code otherwise

◆ copyReferenceImageAttributes()

static OFCondition DicomImageComparison::copyReferenceImageAttributes ( DcmItem src,
DcmItem diffImage 
)
staticprivate

initialize the difference image DICOM dataset by copying all required attributes from the reference image and by generating all other attributes except for the image pixel module, SOP Class UID, and the information to be copied from the test image.

Parameters
srcreference image main dataset
diffImagedifference image main dataset

◆ copyTestImageAttributes()

static OFCondition DicomImageComparison::copyTestImageAttributes ( DcmItem src,
DcmItem diffImage 
)
staticprivate

further populate the difference image DICOM dataset by copying all required attributes from the test image.

Parameters
srcreference image main dataset
diffImagedifference image main dataset

◆ createFrameLabelVector()

static void DicomImageComparison::createFrameLabelVector ( OFString s,
unsigned long  numFrames,
OFBool  isColor 
)
staticprivate

create content for frame label vector

Parameters
sstring to which the frame label vector is written
numFramesnumber of frames present in the reference image
isColortrue if reference image is a color image

◆ initializeDiffImage()

OFCondition DicomImageComparison::initializeDiffImage ( OFCmdFloat  amplify = 1.0)

instruct the DicomImageComparison instance that the creation of a difference image during image comparison is requested.

This function must be called prior to the call to readReferenceImage().

Parameters
amplifyfactor by which all pixel values in the difference image will be multiplied
Returns
EC_Normal if successful, and error code otherwise

◆ logImageInfo()

static void DicomImageComparison::logImageInfo ( DicomImage di,
const char *  filename 
)
staticprivate

print the characteristics of the image to to logger at DEBUG level.

Parameters
diDICOM image
filenamefilename from which the image was loaded

◆ readDICOMImage()

static OFCondition DicomImageComparison::readDICOMImage ( DicomImage *&  di,
OFBool  isReference,
const char *  ifname,
E_TransferSyntax  xfer,
E_FileReadMode  readMode,
unsigned long  compatibilityMode,
DcmItem diffImage 
)
staticprivate

read DICOM image and store pointer to it

Parameters
dipointer to DICOM image, not NULL upon success, NULL otherwise
isReferenceindicates whether we're reading the reference image or the test image
ifnamefilename for DcmFileFormat::loadFile()
xferDICOM transfer syntax for DcmFileFormat::loadFile()
readModefile read mode for DcmFileFormat::loadFile()
compatibilityModecompatibility mode for DicomImage constructor
diffImagepointer to DICOM dataset for difference image, may be NULL
Returns
EC_Normal if successful, and error code otherwise

◆ readReferenceImage()

OFCondition DicomImageComparison::readReferenceImage ( const char *  ifname,
E_TransferSyntax  xfer,
E_FileReadMode  readMode,
unsigned long  compatibilityMode 
)

read reference image for image comparison from file

Parameters
ifnamefilename for DcmFileFormat::loadFile()
xferDICOM transfer syntax for DcmFileFormat::loadFile()
readModefile read mode for DcmFileFormat::loadFile()
compatibilityModecompatibility mode for DicomImage constructor
Returns
EC_Normal if successful, and error code otherwise

◆ readTestImage()

OFCondition DicomImageComparison::readTestImage ( const char *  ifname,
E_TransferSyntax  xfer,
E_FileReadMode  readMode,
unsigned long  compatibilityMode 
)

read test image for image comparison from file

Parameters
ifnamefilename for DcmFileFormat::loadFile()
xferDICOM transfer syntax for DcmFileFormat::loadFile()
readModefile read mode for DcmFileFormat::loadFile()
compatibilityModecompatibility mode for DicomImage constructor
Returns
EC_Normal if successful, and error code otherwise

◆ saveDiffImage()

OFCondition DicomImageComparison::saveDiffImage ( const char *  ofname)

save the difference image created during image comparison.

This function must be called after to the call to computeImageComparisonMetrics().

Parameters
ofnamefilename to be created
Returns
EC_Normal if successful, and error code otherwise

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


Generated on Thu Jan 14 2021 for DCMTK Version 3.6.6 by Doxygen 1.8.18