encaps

package
v0.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package encaps parses DICOM encapsulated (compressed) pixel data. Behaviour aligns with pydicom.encaps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountFragments added in v0.5.0

func CountFragments(fragmentData []byte, littleEndian bool) (int, error)

CountFragments returns the number of fragment items in encapsulated pixel data starting at the first fragment item (after the Basic Offset Table, if any).

func Encapsulate added in v0.19.0

func Encapsulate(frames [][]byte, fragmentsPerFrame int, hasBOT bool) ([]byte, error)

Encapsulate returns encapsulated pixel data for compressed frames. Mirrors pydicom.encaps.encapsulate. Does not append the sequence delimiter; writers emit that for undefined-length OB.

fragmentsPerFrame defaults to 1 when <= 0.

func EncapsulateExtended added in v0.19.0

func EncapsulateExtended(frames [][]byte) (pixelData, offsets, lengths []byte, err error)

EncapsulateExtended returns encapsulated frames (empty BOT) plus Extended Offset Table and Lengths element values. Mirrors pydicom.encaps.encapsulate_extended.

func FragmentFrame added in v0.19.0

func FragmentFrame(frame []byte, nrFragments int) ([][]byte, error)

FragmentFrame splits frame into nrFragments even-sized pieces. The last fragment is padded with 0x00 when needed. Mirrors pydicom fragment_frame.

func GenerateFragmentedFrames

func GenerateFragmentedFrames(pixelData []byte, opts FramesOptions) ([][][]byte, error)

GenerateFragmentedFrames splits encapsulated pixel data into per-frame fragment groups.

func GenerateFrames

func GenerateFrames(pixelData []byte, opts FramesOptions) ([][]byte, error)

GenerateFrames returns one concatenated encoded frame per logical image frame.

func GetFrame

func GetFrame(pixelData []byte, index int, opts FramesOptions) ([]byte, error)

GetFrame returns the encoded data for the frame at index.

func ItemizeFragment added in v0.19.0

func ItemizeFragment(fragment []byte) []byte

ItemizeFragment wraps a fragment as a DICOM Item (FFFE,E000) + length + data.

func ParseBasicOffsets

func ParseBasicOffsets(buf []byte, littleEndian bool) (offsets []uint32, rest []byte, err error)

ParseBasicOffsets reads the Basic Offset Table at the start of encapsulated pixel data. The buffer is consumed through the end of the BOT item; remaining data begins at the first fragment item tag.

Types

type ExtendedOffsetTable

type ExtendedOffsetTable struct {
	Offsets []uint64
	Lengths []uint64
}

ExtendedOffsetTable holds (7FE0,0001) and (7FE0,0002) values.

type FramesOptions

type FramesOptions struct {
	NumberOfFrames  int
	ExtendedOffsets *ExtendedOffsetTable
	LittleEndian    bool // encapsulated item tags use little endian (DICOM default)
}

FramesOptions configures frame generation from encapsulated pixel data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL