Description
Unsigned-word masking and two-complement interpretation/sign extension for at most 32 stored bits; no endian or transfer-syntax decoding.
An image grid has array indices as well as physical spacing, timing, and signal conventions. A calculation on supplied metadata describes one part of that grid or signal; it does not inspect an image, validate a complete file, or interpret anatomy.
Unsigned-word masking and two-complement interpretation/sign extension for at most 32 stored bits; no endian or transfer-syntax decoding.
When to use this tool
Use it for dicom pixel representation signextension mask when the required inputs and conventions are already available.
How to use the tool and how it works
- Enter word, storedBits, allocatedBits, signed. Use the stated units and boundary conventions.
- Run the calculation. Correct any input error before interpreting a result.
- Read maskedWord, interpretedValue, extendedWord. Inspect any known, defined, inclusion, or boundary flags before interpreting numeric values.
Require storedBits from one through 32, allocatedBits between storedBits and 32, and an integer word fitting the allocated width. Mask by remainder modulo 2^storedBits, interpret the stored sign bit when signed, and express the extended value within the allocated width.1
DICOM distinguishes stored pixel bits, allocated bits, and signed versus unsigned representation.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| word | Word | Required. Safe integer; minimum 0. |
| storedBits | Stored Bits | Required. Safe integer; minimum 1; maximum 32. |
| allocatedBits | Allocated Bits | Required. Safe integer; maximum 32. |
| signed | Signed | Required. Boolean. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| maskedWord | Masked Word | Required. Safe integer. |
| interpretedValue | Interpreted Value | Required. Safe integer. |
| extendedWord | Unsigned allocated-width word after sign extension when signed is true. | Required. Safe integer. |
{
"input": {
"word": 4095,
"storedBits": 12,
"allocatedBits": 16,
"signed": true
},
"output": {
"maskedWord": 4095,
"interpretedValue": -1,
"extendedWord": 65535
}
} Limitations and assumptions
- This arithmetic avoids treating the highest 32-bit flag as a negative JavaScript bitwise result. It does not decode byte order, compressed pixels, or arbitrary DICOM High Bit layouts. Accepted numeric bit widths are broader than DICOM encoding rules; this is not a file-conformance check.
- The field tables describe structural bounds; the mechanics also state cross-field requirements. Malformed input shapes, disallowed keys, and invalid domains cause input errors. Results must remain finite and within the declared output contract. A successful false flag or zero placeholder is distinct from an error.
- Numeric arithmetic uses binary floating point. Exact comparisons have no hidden tolerance or decimal rounding; negative zero is exported as zero. Decimal-text integer operations retain the exactness specifically stated above.
Alternative or Complementary methods
For dicom pixel representation signextension mask, check the source records and the supplied rule before comparing the result with another method. Use a full image reader and geometry or signal analysis when the task requires interpreting image data.
References
Similar or alternative tools
- DICOM Overlay Bit Position Mask
Unsigned 32-bit stored-word bit extraction and clearing, without signed JavaScript shift coercion or decoding an overlay plane.
- DICOM Pixel Spacing Row Column Crosswalk
DICOM Pixel Spacing order is row then column, in millimeters; distances are in the image plane, not patient-coordinate reconstruction.