You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The vtkDICOMValue class has AsInt(), AsDouble(), AsString() etc. methods for extracting the value of a DICOM data element. This extraction can result in loss of precision. For example:
extracting 'DS' with AsDouble() or AsFloat() is inexact (decimal mantissa to binary mantissa)
extracting 'DS' with AsInt() results in truncation
Of course, the only lossless way to extract 'DS' is with AsString(), but that is not useful when the value is to be used as a number.
For each VR, each conversion can be characterized as:
exact
inexact (DS to floating-point)
loss of precision (truncation, or insufficient bits)
signed to unsigned or vice-versa
nonsensical (value not representable after conversion)
Whenever a conversion is not exact, it might be good to have a warning produced at runtime if the code is compiled in debug mode. The signed/unsigned is tricky because sometimes DICOM is hazy on 'US' vs. 'SS', e.g. for implicit VR it can depend on PixelRepresentation. Also, the first/third values in the lookup table descriptor are always to be interpreted as unsigned even if the VR is 'SS'.
The text was updated successfully, but these errors were encountered:
Of course, it would be better to report precision loss at compile time. For example, GDCM uses a template to map tags to VRs and from there to type and encoding: 'DS' has type 'double' and encoding 'ascii'. Philosophically, this is very different from vtk-dicom where the dictionary is simply a data structure. Architecturally, vtk-dicom uses metaprogramming only in its implementation, never in its interface.
The vtkDICOMValue class has AsInt(), AsDouble(), AsString() etc. methods for extracting the value of a DICOM data element. This extraction can result in loss of precision. For example:
Of course, the only lossless way to extract 'DS' is with AsString(), but that is not useful when the value is to be used as a number.
For each VR, each conversion can be characterized as:
Whenever a conversion is not exact, it might be good to have a warning produced at runtime if the code is compiled in debug mode. The signed/unsigned is tricky because sometimes DICOM is hazy on 'US' vs. 'SS', e.g. for implicit VR it can depend on PixelRepresentation. Also, the first/third values in the lookup table descriptor are always to be interpreted as unsigned even if the VR is 'SS'.
The text was updated successfully, but these errors were encountered: