Documentation
¶
Index ¶
- Variables
- func DecodeFrame(src []byte, nrPixels int, bitsAllocated int, byteOrder ByteOrder) ([]byte, error)
- func DecodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
- func DecodeSegment(src []byte) ([]byte, error)
- func EncodeFrame(src []byte, rows, cols, spp, bitsAllocated int, byteOrder ByteOrder) ([]byte, error)
- func EncodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
- func EncodeRow(src []byte) ([]byte, error)
- func EncodeSegment(src []byte, cols int) ([]byte, error)
- func PackBits(src []byte, byteOrder ByteOrder) ([]byte, error)
- func Packed1BitLength(rows, cols int) int
- func ParseHeader(src []byte) ([]uint32, error)
- func UnpackBits(src []byte, count int, byteOrder ByteOrder) ([]byte, error)
- func UnpackedFrameLength(rows, cols, spp, bitsAllocated int) int
- type ByteOrder
- type FrameOptions
- type PixelDataOptions
- type PixelDataVersion
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidHeaderLength = errors.New("the RLE header must be 64 bytes long") ErrInvalidSegmentOffset = errors.New("invalid segment offset found in the RLE header") ErrInsufficientData = errors.New("frame is not long enough to contain RLE encoded data") ErrInvalidBitsAllocated = errors.New("the (0028,0100) 'Bits Allocated' value must be 1, 8, 16, 32 or 64") ErrInvalidSamplesPerPixel = errors.New("the (0028,0002) 'Samples per Pixel' must be 1 or 3") ErrSamplesPerPixelBA1 = errors.New("the (0028,0002) 'Samples per Pixel' must be 1 if (0028,0100) 'Bits Allocated' is 1") ErrSegmentLength = errors.New("the decoded segment length does not match the expected length") ErrInvalidByteOrder = errors.New("'byteorder' must be '>' or '<'") ErrSegmentDecodeEOF = errors.New("the end of the data was reached before the segment was completely decoded") ErrTooManySegments = errors.New("unable to encode as the DICOM Standard only allows a maximum of 15 segments in RLE encoded data") ErrInvalidParameters = errors.New("the length of the data to be encoded is not consistent with the values of the dataset's 'Rows', 'Columns', 'Samples per Pixel' and 'Bits Allocated' elements") ErrInvalidColumns = errors.New("the (0028,0011) 'Columns' value is invalid") ErrInvalidPackBitsInput = errors.New("only binary input (containing zeros or ones) can be packed") ErrMissingPixelDataArgs = errors.New("missing expected keyword arguments: bits_allocated, columns, rows") ErrUnsupportedPixelVersion = errors.New("gorle: unsupported pixel data version") )
Functions ¶
func DecodeFrame ¶
DecodeFrame decodes a single RLE Lossless frame.
func DecodePixelData ¶
func DecodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
DecodePixelData decodes a single RLE Lossless frame (pylibjpeg-rle decode_pixel_data).
func DecodeSegment ¶
DecodeSegment decodes a single RLE segment (PackBits).
func EncodeFrame ¶
func EncodeFrame(src []byte, rows, cols, spp, bitsAllocated int, byteOrder ByteOrder) ([]byte, error)
EncodeFrame encodes planar-configuration-0 pixel data (R1,G1,B1,R2,…).
func EncodePixelData ¶
func EncodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
EncodePixelData encodes a single frame using DICOM RLE (pylibjpeg-rle encode_pixel_data).
func EncodeSegment ¶
EncodeSegment encodes a segment. cols is the number of values per row.
func Packed1BitLength ¶
Packed1BitLength returns packed 1-bit frame size in bytes.
func ParseHeader ¶
ParseHeader returns the 15 segment offsets from a 64-byte RLE header. Bytes 0–3 hold the segment count; offsets are little-endian uint32 values starting at byte 4 (DICOM PS3.5 G.3).
func UnpackBits ¶
UnpackBits unpacks bit-packed data. count is the number of bits to return; zero means unpack the entire input.
func UnpackedFrameLength ¶
UnpackedFrameLength returns the decoded frame length in bytes for validation.
Types ¶
type FrameOptions ¶
type FrameOptions struct {
Rows int
Columns int
SamplesPerPixel int
BitsAllocated int
ByteOrder ByteOrder
}
FrameOptions configures single-frame RLE encode/decode.
type PixelDataOptions ¶
type PixelDataOptions struct {
Version PixelDataVersion
FrameOptions
PackBits bool // v2 only: return 1-bit data packed when BitsAllocated is 1
}
PixelDataOptions configures DecodePixelData / EncodePixelData.
type PixelDataVersion ¶
type PixelDataVersion int
PixelDataVersion selects decode_pixel_data behaviour.
const ( PixelDataV1 PixelDataVersion = 1 PixelDataV2 PixelDataVersion = 2 )