Skip to content
Back to skills

Dicom Voi Lut Preprocessing

ASecurity

Read DICOM X-ray files with VOI LUT transformation and MONOCHROME1 inversion for correct pixel intensity rendering

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
developmentpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill dicom-voi-lut-preprocessing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dicom Voi Lut Preprocessing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dicom Voi Lut Preprocessing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-dicom-voi-lut-preprocessing/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-dicom-voi-lut-preprocessing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cv-dicom-voi-lut-preprocessing
description: Read DICOM X-ray files with VOI LUT transformation and MONOCHROME1 inversion for correct pixel intensity rendering
domain: cv
---

# DICOM VOI LUT Preprocessing

## Overview

X-ray DICOM files use Value of Interest (VOI) Lookup Tables to map stored pixel values to display-ready intensities. Some scanners store images as MONOCHROME1 (inverted — bright=air, dark=tissue), which must be flipped. Apply VOI LUT first, then fix photometric interpretation, then normalize to 0-255.

## Quick Start

```python
import numpy as np
import pydicom
from pydicom.pixel_data_handlers.util import apply_voi_lut

def read_xray(path, voi_lut=True, fix_monochrome=True):
    """Read and preprocess a DICOM X-ray image.
    
    Args:
        path: path to .dcm file
        voi_lut: apply VOI LUT transform (recommended)
        fix_monochrome: invert MONOCHROME1 images
    Returns:
        uint8 image array (0-255)
    """
    dicom = pydicom.dcmread(path)
    if voi_lut:
        data = apply_voi_lut(dicom.pixel_array, dicom)
    else:
        data = dicom.pixel_array
    if fix_monochrome and dicom.PhotometricInterpretation == "MONOCHROME1":
        data = np.amax(data) - data
    data = data - np.min(data)
    data = data / np.max(data)
    data = (data * 255).astype(np.uint8)
    return data

img = read_xray("patient001.dcm")
```

## Key Decisions

- **VOI LUT vs raw**: VOI LUT applies manufacturer-calibrated display mapping; skip only for custom windowing
- **MONOCHROME1 inversion**: without this fix, lung appears white and bone black — confuses models
- **Min-max normalization**: handles variable bit depths (12-bit, 16-bit) across scanners
- **uint8 output**: compatible with standard CV pipelines and augmentation libraries

## References

- Source: [siim-cov19-efnb7-yolov5-infer](https://www.kaggle.com/code/h053473666/siim-cov19-efnb7-yolov5-infer)
- Competition: SIIM-FISABIO-RSNA COVID-19 Detection

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.