Documentation
¶
Index ¶
- Constants
- Variables
- func DecodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
- func Encode(src []byte, opts EncodeOptions) ([]byte, error)
- func EncodePixelData(src []byte, opts PixelDataOptions, frame EncodeOptions) ([]byte, error)
- func OpenJPEGVersion() (string, error)
- func ReadStream(stream any) ([]byte, error)
- type Codec
- type EncodeOptions
- type Image
- type Params
- type PixelDataOptions
- type PixelDataVersion
- type ProgressionOrder
Constants ¶
const ( ColourUnspecified = 0 ColourSRGB = 1 ColourGray = 2 ColourSYCC = 3 ColourEYCC = 4 ColourCMYK = 5 )
Colour spaces matching OpenJPEG OPJ_COLOR_SPACE.
Variables ¶
var ErrUnsupportedPlatform = native.ErrUnsupportedPlatform
ErrUnsupportedPlatform reports that this GOOS/GOARCH has no prebuilt native library, so JPEG 2000 data can be neither decoded nor encoded here. Every function in this package returns an error wrapping it rather than panicking, which keeps the module importable everywhere Go builds. Test for it with errors.Is. The README lists the platforms that do have a library.
Functions ¶
func DecodePixelData ¶
func DecodePixelData(src []byte, opts PixelDataOptions) ([]byte, error)
DecodePixelData decodes encapsulated JPEG 2000 pixel data for DICOM. Version 2 returns raw decoded bytes; version 1 matches pylibjpeg v1 behaviour.
func Encode ¶ added in v1.1.0
func Encode(src []byte, opts EncodeOptions) ([]byte, error)
Encode encodes little-endian colour-by-pixel samples to JPEG 2000.
func EncodePixelData ¶ added in v1.1.0
func EncodePixelData(src []byte, opts PixelDataOptions, frame EncodeOptions) ([]byte, error)
EncodePixelData encodes a single DICOM frame for JPEG 2000 transfer syntaxes.
func OpenJPEGVersion ¶
OpenJPEGVersion returns the linked openjpeg library version.
func ReadStream ¶
ReadStream reads JPEG 2000 data from bytes, a file path, or an io.Reader.
Types ¶
type Codec ¶
type Codec int
Codec selects the JPEG 2000 container format (pylibjpeg-openjpeg codec argument).
type EncodeOptions ¶ added in v1.1.0
type EncodeOptions struct {
Columns int
Rows int
SamplesPerPixel int
BitsStored int
IsSigned bool
ColourSpace int
UseMCT bool
Codec Codec
// ProgressionOrder applies to HTJ2K encode (.201 LRCP, .202 RPCL).
ProgressionOrder ProgressionOrder
// CompressionRatios empty => lossless (DWT 5-3).
CompressionRatios []float64
}
EncodeOptions configures Encode / EncodePixelData.
type Image ¶
type Image struct {
Pixels []byte
Width int
Height int
Components int
Precision int
IsSigned bool
ColourSpace int
}
Image holds decoded pixel data in native precision, planar-interleaved (DICOM order).
func DecodeImage ¶
DecodeImage decodes JPEG 2000 data (pylibjpeg-openjpeg decode()).
func (*Image) BytesPerSample ¶
type Params ¶
type Params struct {
Width int
Height int
Components int
Precision int
IsSigned bool
ColourSpace int
}
Params holds JPEG 2000 image parameters without decoding pixels.
func GetImageParameters ¶
GetImageParameters reads JPEG 2000 parameters without decoding pixels.
func GetParameters ¶
GetParameters is a shorthand for GetImageParameters with CodecJ2K.
func (*Params) NrComponents ¶
type PixelDataOptions ¶
type PixelDataOptions struct {
Version PixelDataVersion
Codec Codec
PhotometricInterpretation string
}
PixelDataOptions configures DecodePixelData for DICOM handlers.
type PixelDataVersion ¶
type PixelDataVersion int
PixelDataVersion selects decode_pixel_data behaviour.
const ( PixelDataV1 PixelDataVersion = 1 PixelDataV2 PixelDataVersion = 2 )
type ProgressionOrder ¶ added in v1.2.0
type ProgressionOrder int
ProgressionOrder selects HTJ2K packet progression (DICOM .201 vs .202).
const ( ProgressionLRCP ProgressionOrder = 0 // HTJ2K Lossless (.201) ProgressionRPCL ProgressionOrder = 1 // HTJ2K Lossless RPCL (.202) )