Skip to main content
Medical imaging uses various compression formats to balance image quality with file size. Miele-LXIV Easy integrates multiple image format libraries to support the full range of DICOM transfer syntaxes and display formats.

Overview

The build system compiles five major image format libraries:

JPEG

Standard lossy compression (JPEG baseline)

TIFF

Multi-page image storage and lossless compression

PNG

Lossless compression for screenshots and displays

OpenJPEG

JPEG 2000 compression (lossy and lossless)

Jasper

Alternative JPEG 2000 implementation

JPEG (libjpeg)

Purpose

The Independent JPEG Group’s library handles standard JPEG compression. In medical imaging, JPEG is used for:
  • DICOM Transfer Syntax 1.2.840.10008.1.2.4.50: JPEG Baseline (lossy)
  • Preview Images: Thumbnails and quick previews
  • Screen Captures: Exporting views for reports
Lossy JPEG should not be used for diagnostic images where image quality is critical. Many institutions only allow lossless compression for primary diagnostic images.

Version & Configuration

JPEG_VERSION=9d

Build Process

JPEG uses a traditional autotools build:
build.sh:314-340
if [ $STEP_DOWNLOAD_LIB_JPEG ] && [ ! -d $SRC_JPEG ] ; then
cd $SRC
curl -O http://www.ijg.org/files/jpegsrc.v$JPEG_VERSION.tar.gz
tar -zxf jpegsrc.v$JPEG_VERSION.tar.gz
rm jpegsrc.v$JPEG_VERSION.tar.gz
fi

if [ $STEP_CONFIGURE_LIB_JPEG ] ; then
echo "=== Configure LIBJPEG in $BLD_JPEG"
mkdir -p $BLD_JPEG ; cd $BLD_JPEG
$SRC_JPEG/configure --prefix=$BIN_JPEG
fi

if [ $STEP_COMPILE_LIB_JPEG ] ; then
cd $BLD_JPEG
echo "=== Build LIBJPEG"
make $MAKE_FLAGS
echo "=== Install LIBJPEG"
make install
fi

TIFF (libtiff)

Purpose

TIFF (Tagged Image File Format) provides:
  • Multi-page Storage: Multiple images in one file
  • Lossless Compression: LZW, ZIP compression
  • Metadata: Rich tagging system
  • High Bit Depths: 12-bit, 16-bit images
TIFF is used for exporting image series and archival storage.

Version & Configuration

TIFF_VERSION=4.0.10

Build Configuration

TIFF is built with CMake and depends on JPEG:
build.sh:355-373
$CMAKE -G"$GENERATOR" \
    -D CMAKE_INSTALL_PREFIX=$BIN_TIFF \
    -D CMAKE_OSX_ARCHITECTURES=$OSX_ARCHITECTURES \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_OSX_DEPLOYMENT_TARGET=$DEPL_TARG \
    -D BUILD_SHARED_LIBS=OFF \
    -D BUILD_DOCUMENTATION=OFF \
    -D BUILD_TESTING=OFF \
    -D lzma=OFF \
    -D zstd=OFF \
    -D webp=OFF \
    -D JPEG_INCLUDE_DIR=$BIN_JPEG/include \
    -D JPEG_LIBRARY=$BIN_JPEG/lib/libjpeg.a \
    -D CMAKE_CXX_FLAGS="$COMPILER_FLAGS" \
    $SRC_TIFF

Post-Install Patching

TIFF headers are patched to avoid type conflicts:
build.sh:383-386
sed -i '' -e "s/typedef TIFF_UINT64_T/\/\/typedef TIFF_UINT64_T/g" "$BIN_TIFF/include/tiff.h"
sed -i '' -e "s/uint64 tiff_diroff/TIFF_UINT64_T tiff_diroff/g" "$BIN_TIFF/include/tiff.h"
sed -i '' -e "s/uint64/TIFF_UINT64_T/g" "$BIN_TIFF/include/tiffio.h"
These modifications prevent type collisions on macOS.

PNG (libpng)

Purpose

PNG (Portable Network Graphics) provides lossless compression for:
  • Screen Captures: Export visualizations
  • Overlays: Annotations and graphics
  • Web Display: Share images online
PNG is not used for primary DICOM storage but for display and export.

Version & Configuration

PNG_VERSION=1.6.37

Build Configuration

build.sh:207-219
$CMAKE -G"$GENERATOR" \
    -D CMAKE_INSTALL_PREFIX=$BIN_PNG \
    -D CMAKE_OSX_ARCHITECTURES=$OSX_ARCHITECTURES \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_OSX_DEPLOYMENT_TARGET=$DEPL_TARG \
    -D PNG_FRAMEWORK=ON \
    -D BUILD_SHARED_LIBS=ON \
    -D CMAKE_CXX_FLAGS="$COMPILER_FLAGS" \
    $SRC_PNG
PNG is built as a shared library (BUILD_SHARED_LIBS=ON) and framework, unlike most other dependencies which use static linking.

OpenJPEG

Purpose

OpenJPEG is an open-source JPEG 2000 codec supporting:
  • JPEG 2000 Compression: Both lossy and lossless
  • High Bit Depths: 12-bit, 16-bit medical images
  • Better Quality: Superior to JPEG at same compression ratios
  • DICOM Transfer Syntaxes: Multiple J2K variants
JPEG 2000 is increasingly popular in medical imaging for its quality and flexibility.

Version & Configuration

OPENJPG_MAJOR=2
OPENJPG_MINOR=3
OPENJPG_BUILD=1
OPENJPG_VERSION=2.3.1

Build Configuration

build.sh:658-670
$CMAKE -G"$GENERATOR" \
    -D CMAKE_INSTALL_PREFIX=$BIN_OPENJPG \
    -D CMAKE_OSX_ARCHITECTURES=$OSX_ARCHITECTURES \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_OSX_DEPLOYMENT_TARGET=$DEPL_TARG \
    -D CMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -D BUILD_SHARED_LIBS=OFF \
    -D BUILD_THIRDPARTY=ON \
    -D CMAKE_CXX_FLAGS="$COMPILER_FLAGS" \
    $SRC_OPENJPG

Patching

OpenJPEG requires patches for compatibility:
patch/openjpeg-2.3.1_miele-easy-8.4.62.patch
build.sh:644-650
if [ $STEP_PATCH_OPENJPG ] ; then
cd $SRC_OPENJPG
echo "=== Patch OpenJPEG"
if [ -f $PATCH_DIR/$PATCH_FILENAME ] ; then
patch -p1 -i $PATCH_DIR/$PATCH_FILENAME
fi
fi

Post-Install

Additional headers are copied after installation:
build.sh:684
cp $SRC_OPENJPG/src/bin/common/format_defs.h $BIN_OPENJPG/include

Jasper

Purpose

Jasper is an alternative JPEG 2000 implementation. Miele-LXIV includes both OpenJPEG and Jasper for maximum compatibility with different JPEG 2000 variants.

Version & Configuration

JASPER_VERSION=2.0.32

Build Configuration

build.sh:699-712
$CMAKE -G"$GENERATOR" \
    -D CMAKE_INSTALL_PREFIX=$BIN_JASPER \
    -D CMAKE_OSX_ARCHITECTURES=$OSX_ARCHITECTURES \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_OSX_DEPLOYMENT_TARGET=$DEPL_TARG \
    -D CMAKE_EXPORT_COMPILE_COMMANDS=ON \
    -D CMAKE_CXX_FLAGS="$COMPILER_FLAGS" \
    -D JAS_ENABLE_AUTOMATIC_DEPENDENCIES=OFF \
    -D JAS_ENABLE_SHARED=OFF \
    -D JAS_ENABLE_PROGRAMS=OFF \
    $SRC_JASPER
OptionPurpose
JAS_ENABLE_SHARED=OFFBuild static library
JAS_ENABLE_PROGRAMS=OFFDon’t build command-line tools
JAS_ENABLE_AUTOMATIC_DEPENDENCIES=OFFManage dependencies manually

Library Dependencies

The image libraries have interdependencies:

DICOM Transfer Syntax Support

These libraries enable support for DICOM transfer syntaxes:
Transfer SyntaxLibraryDescription
1.2.840.10008.1.2.4.50JPEGJPEG Baseline (lossy, 8-bit)
1.2.840.10008.1.2.4.51JPEGJPEG Extended (lossy, 12-bit)
1.2.840.10008.1.2.4.57JPEGJPEG Lossless, Non-Hierarchical
1.2.840.10008.1.2.4.70JPEGJPEG Lossless, First-Order Prediction
1.2.840.10008.1.2.4.80OpenJPEG/JasperJPEG-LS Lossless
1.2.840.10008.1.2.4.90OpenJPEG/JasperJPEG 2000 Lossless
1.2.840.10008.1.2.4.91OpenJPEG/JasperJPEG 2000 Lossy
DCMTK automatically uses the appropriate library based on the transfer syntax of the DICOM file being loaded.

Configuration in Kconfig

Kconfig-miele:34-39
config DOWNLOAD_LIB_JPEG
    bool "lib jpeg"
    default y

config DOWNLOAD_LIB_TIFF
    bool "lib tiff"
    default y

config DOWNLOAD_LIB_PNG
    bool "lib png"
    default y

config DOWNLOAD_SOURCES_OPENJPG
    bool "OpenJPEG"
    default y

config DOWNLOAD_SOURCES_JASPER
    bool "Jasper"
    default y

Build Order

The image libraries must be built in this order due to dependencies:
  1. JPEG (no dependencies)
  2. PNG (no dependencies)
  3. TIFF (depends on JPEG)
  4. OpenJPEG (no dependencies)
  5. Jasper (no dependencies)
  6. VTK (uses JPEG, TIFF, PNG)
  7. DCMTK (uses all image libraries)
The build script handles this ordering automatically.

Common Issues

TIFF Type Conflicts

If you see errors about uint64 type conflicts, ensure the post-install patching step ran:
# This should be automatic, but can be run manually:
sed -i '' -e "s/uint64/TIFF_UINT64_T/g" "$BIN_TIFF/include/tiffio.h"

OpenJPEG Linking

Ensure the format_defs.h header was copied:
ls $BIN_OPENJPG/include/format_defs.h
If missing, copy it manually from build.sh:684.

Further Reading

libjpeg

Independent JPEG Group homepage

libtiff

LibTIFF documentation

OpenJPEG

OpenJPEG GitHub repository

JPEG 2000 Standard

JPEG 2000 specifications

Build docs developers (and LLMs) love