DCMTK: DicomImageComparison Class Reference

DCMTK Version 3.6.9 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
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.
OFCondition | saveDiffImage (const char *ofname)
| save the difference image created during image comparison.
OFCondition | readReferenceImage (const char *ifname, E_TransferSyntax xfer, E_FileReadMode readMode, unsigned long compatibilityMode)
| read reference image for image comparison from file
OFCondition | readTestImage (const char *ifname, E_TransferSyntax xfer, E_FileReadMode readMode, unsigned long compatibilityMode)
| read test image for image comparison from file
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.
OFCondition | computeImageComparisonMetrics (EW_WindowType windowType)
| compare both images and compute image comparison metrics.
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
DicomImageComparison & | operator= (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).
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.
OFCondition | computeMonochromeImageComparionMetricsRaw ()
| compare two monochrome images without setting a VOI window.
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.
OFCondition | computeColorImageComparionMetrics ()
| compare two images that are both color images.

## 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
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.
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.
static OFCondition | copyTestImageAttributes (DcmItem *src, DcmItem *diffImage)
| further populate the difference image DICOM dataset by copying all required attributes from the test image.
static void | logImageInfo (DicomImage *di, const char *filename)
| print the characteristics of the image to to logger at DEBUG level.
static void | createFrameLabelVector (OFString &s, unsigned long numFrames, OFBool isColor)
| create content for frame label vector

## Private Attributes
DicomImage * | di_reference
| pointer to reference image
DicomImage * | di_test
| pointer to test image
DcmFileFormat * | diff_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 comparison metrics.

Parameters

  windowType | VOI 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

  di | DICOM image, must not be NULL
  windowType | VOI LUT transformation to apply
  windowParameter | index of VOI LUT/window in file (if windowType is EWT_window_from_file or EWT_voi_lut_from_file)
  windowCenter | window center (input for EWT_window_parameters, output for EWT_window_min_max and EWT_window_min_max_n)
  windowWidth | window width (input for EWT_window_parameters, output for EWT_window_min_max and EWT_window_min_max_n)
  voiFunction | VOI LUT function (linear or sigmoid)
  presShape | Presentation LUT Shape (identity, reverse, lin OD)
  depth | bit 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

  windowType | VOI LUT transformation to apply
  sharedWindow | compute common min/max window for both images if true, separate windows if false
  windowParameter | index of VOI LUT/window in file (if windowType is EWT_window_from_file or EWT_voi_lut_from_file)
  windowCenter | window center (ignored unless windowType is EWT_window_parameters)
  windowWidth | window width (ignored unless windowType is EWT_window_parameters)
  voiFunction | VOI LUT function (linear or sigmoid)
  presShape | Presentation 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

  src | reference image main dataset
  diffImage | difference 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

  src | reference image main dataset
  diffImage | difference image main dataset

## ◆ createFrameLabelVector()

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

create content for frame label vector

Parameters

  s | string to which the frame label vector is written
  numFrames | number of frames present in the reference image
  isColor | true 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

  amplify | factor 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

  di | DICOM image
  filename | filename 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

  di | pointer to DICOM image, not NULL upon success, NULL otherwise
  isReference | indicates whether we're reading the reference image or the test image
  ifname | filename for DcmFileFormat::loadFile()
  xfer | DICOM transfer syntax for DcmFileFormat::loadFile()
  readMode | file read mode for DcmFileFormat::loadFile()
  compatibilityMode | compatibility mode for DicomImage constructor
  diffImage | pointer 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

  ifname | filename for DcmFileFormat::loadFile()
  xfer | DICOM transfer syntax for DcmFileFormat::loadFile()
  readMode | file read mode for DcmFileFormat::loadFile()
  compatibilityMode | compatibility 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

  ifname | filename for DcmFileFormat::loadFile()
  xfer | DICOM transfer syntax for DcmFileFormat::loadFile()
  readMode | file read mode for DcmFileFormat::loadFile()
  compatibilityMode | compatibility 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

  ofname | filename to be created

Returns
  EC_Normal if successful, and error code otherwise

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

- dcmimage/include/dcmtk/dcmimage/dcmicmph.h

Generated on Sat Mar 1 2025 for DCMTK Version 3.6.9 by Doxygen 1.13.2