Skip to content

jpfielding/dicos.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dicos.rs

A pure-Rust library and toolkit for working with DICOS (Digital Imaging and Communication in Security) files. DICOS is the NEMA IIC 1 standard used by security screening equipment (CT scanners, X-ray systems) to encode volumetric and projection image data. It is closely related to DICOM but tailored for aviation and checkpoint security workflows.

This project implements the NEMA IIC 1 v04-2023 specification and provides:

  • A core parsing library for reading DICOS datasets and pixel data.
  • Four standalone lossless compression codecs (no DICOS dependency).
  • A CLI tool (dicosctl) for inspecting files from the terminal.
  • A GPU-accelerated volume viewer (roxel) with 3D ray-casting and 2D slice display.

Ported from dicos.go. Pure Rust -- no C dependencies.

Project Components

dicos -- Core Library

The dicos crate parses DICOS/DICOM binary files into an in-memory Dataset of typed elements. It handles explicit and implicit VR transfer syntaxes, encapsulated pixel data, and multi-frame volumes. Codec crates are wired in through optional feature flags so downstream consumers only pay for what they use.

Compression Codecs

Pure Rust implementations of the lossless image compression formats used by DICOS and DICOM. Each codec is a standalone crate with zero dependency on dicos, so they can be used independently in any imaging pipeline.

Crate Standard Algorithm Use Case
jpeg2k ITU-T T.800 Wavelet (DWT + EBCOT) Excellent compression ratio
jpegli ITU-T T.81 Annex H DPCM (Process 14 SV1) Traditional lossless JPEG
jpegls ISO/IEC 14495-1 / ITU-T T.87 LOCO-I Very efficient, near-entropy
jpegrle DICOM Part 5 Section 8.1.1 PackBits RLE Simple run-length encoding

dicosctl -- CLI Inspector

A command-line tool for quick inspection of DICOS files. Built as a binary inside the dicos crate behind the cli feature flag.

roxel -- GPU Volume Viewer

A three-panel desktop application for visualizing 3D CT volumes and 2D slices from DICOS files. Uses wgpu for GPU ray-casting and egui for the UI.

roxel 3D Rendering

+------------+------------------------+------------------------+
| Sidebar    |   3D Volume View       |   2D Slice View        |
|            |   (GPU ray-caster)     |   (CPU rendered)       |
| Metadata   |                        |                        |
| Layers     +------------------------+------------------------+
| Threats    | Quality | Opacity      | Volume: [dropdown]     |
|            | Preset  | Bands        | View:   [dropdown]     |
|            | Lighting | WC/WW       | Composite [x]          |
|            |                        | W/L: __ W/W: __        |
|            |                        | Slice: [slider]        |
+------------+------------------------+------------------------+
  • Left sidebar -- file open, metadata display, volume layer toggles, rendering quality, transfer function presets (Bands / Threat / Monochrome), material band sliders, and Phong lighting controls.
  • Center panel -- GPU ray-cast 3D volume rendering with arcball camera (left-drag to rotate, scroll to zoom, axial/coronal/sagittal preset views).
  • Right panel -- CPU-rendered 2D slice viewer with orientation selector, window/level controls, slice index slider, and MIP composite toggle.

Requires a GPU with Vulkan, Metal, or DX12 support.

Workspace Structure

dicos.rs/
  Cargo.toml              # Workspace root
  testdata/               # Public-safe synthetic fixtures
  crates/
    dicos/                # Core DICOS library + dicosctl binary
    jpegrle/              # RLE PackBits codec (standalone)
    jpegls/               # JPEG-LS codec (standalone)
    jpegli/               # JPEG Lossless codec (standalone)
    jpeg2k/               # JPEG 2000 codec (standalone)
    roxel/                # GPU-accelerated volume viewer

Dependency Graph

jpegrle ----+
jpegls  ----|  (standalone, zero dicos dependency)
jpegli  ----|
jpeg2k  ----+
                dicos --> optionally uses codec crates via feature flags
                  |       includes dicosctl binary (--features cli)
                  |
           roxel --> dicos + wgpu + egui

Building

# Build the entire workspace
cargo build --workspace

# Run all tests
cargo test --workspace

# Build dicosctl (the CLI tool)
cargo build -p dicos --features cli

# Build roxel in release mode (recommended for interactive use)
cargo build -p roxel --release

Usage

dicosctl

# Print a human-readable summary of a DICOS file
cargo run -p dicos --features cli -- info scan.dcs

# Example output:
#   File: scan.dcs
#   Elements: 42
#   Modality: CT
#   Dimensions: 512x512
#   Frames: 256
#   Bits Allocated: 16
#   Transfer Syntax: JPEG-LS Lossless (1.2.840.10008.1.2.4.80)
#   SOP Class: 1.2.840.10008.5.1.4.1.1.501.2.1
#   Manufacturer: L3 Technologies
#   Model: CX100

# Dump all metadata as JSON
cargo run -p dicos --features cli -- dump scan.dcs

# Pipe JSON output to jq for querying
cargo run -p dicos --features cli -- dump scan.dcs | jq '.Modality'

# Compact (non-pretty) JSON
cargo run -p dicos --features cli -- dump --no-pretty scan.dcs

roxel

# Launch with an empty viewport, then use File > Open to load
cargo run -p roxel --release

# Load a single DICOS file directly
cargo run -p roxel --release -- scan.dcs

# Load a directory of single-frame .dcs files as one volume
cargo run -p roxel --release -- /path/to/slices/

Mouse controls:

Action Effect
Left-drag in 3D view Rotate volume (arcball)
Scroll wheel Zoom in/out

Transfer function presets:

Preset Description
Default Five-band material: Air (transparent), Organic (orange), Inorganic (green), Metal (blue), Dense (dark blue)
Threat Red monochrome for threat highlighting
Mono Grayscale density mapping

See crates/roxel/README.md for full documentation including architecture, rendering pipeline, and GPU requirements.

Test Results

dicos:   87 passed, 0 failed
roxel:   31 passed, 0 failed
jpeg2k:  62 passed, 0 failed
jpegli:  51 passed, 0 failed
jpegls:  61 passed, 0 failed
jpegrle: 29 passed, 0 failed
---------------------------------
Total:  321 passed, 0 failed, 0 ignored

References

Acknowledgements

Built with Claude Code by Anthropic and Codex.

About

A DICOS (etc) library for Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors