openjpeg_go

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

README

openjpeg GitHub tag (latest by date)

golang wrapper for openjpeg library v2.5.0

description

only tested on windows x64 (Windows 7 Windows 10) Mac OS X 13 centos 7 ubuntu 22.04. you should test it yourself for other platforms.

usage

refer to example dir

import openjpeg "github.com/linxlib/openjpeg"

build

install golang > 1.18 first

Windows

  • install MSYS2
  • add C:\msys64\mingw64\bin to PATH environment
  • open MSYS2 MSYS from start menu, install gcc with pacman -S mingw-w64-x86_64-gcc
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg\example
  • go run -v .\main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

Linux (Centos 7)

The version of openjpeg in package manager may not the latest (v2.5.0), so we need to build from source.

build and install openjpeg 2.5.0 (optional)
  • install gcc cmake ...etc
  • wget https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.5.0.zip
  • unzip v2.5.0.zip && cd openjpeg-2.5.0/
  • mkdir build && cd build
  • cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:bool=on
  • make
  • make install
  • you will find openjpeg(libopenjp2) library and in /usr/local/lib /usr/local/include ...
run
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg\example
  • go run main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

Mac OS X

May be you don't need to install openjpeg just like linux.

  • configure cgo compile environment by yourself
  • if you have installed ffmpeg, so openjpeg 2.5.0 already installed, just skip the next step
  • brew install openjpeg and make sure opj_decompress -h can get something like openjp2 library v2.5.0
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg/example
  • go run main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

TODO

  • cross compile (compile executable file in only one platform (may be docker))
  • add some other platforms support

Documentation

Index

Constants

View Source
const YCbCrSubsampleRatioUnknown = -1

Variables

This section is empty.

Functions

func Crop

func Crop(i image.Image, rectangle *image.Rectangle) image.Image

func Decode

func Decode(r io.Reader) (img image.Image, err error)

func DecodeConfig

func DecodeConfig(r io.Reader) (cfg image.Config, err error)

func Encode

func Encode(o io.WriteSeeker, img image.Image, opt *Options) (err error)

func GetPixStride

func GetPixStride(i image.Image) ([]byte, int)

func GetSSR

Get sub-sampling ratio if color space has one (0 = no sub-sampling).

func IsGray

func IsGray(img image.Image, fuzz int) bool

func NewImage

func NewImage(c color.Model, r image.Rectangle) image.Image

Create a new Image of specified color model.

func NewImageColorAs

func NewImageColorAs(template image.Image, r image.Rectangle)

Create a new image "in the image" of template, that is, of same color model.

func SSR2VHDiv

func SSR2VHDiv(i image.YCbCrSubsampleRatio) (v, h int)

Translate Go's sub-sampling rate to V/H divisors.

func ToGray

func ToGray(img image.Image, fuzz int) (gr *image.Gray)

Attempt conversion of the input image into greyscale. Fuzz is is a threshold when a color picture is considered greyscale, Higher fuzz will accept more of color variance. If picture is above fuzz, "too colorish", nil is returned. If fuzz threshold is -1, the conversion is done always.

func ToModel

func ToModel(img image.Image, c color.Model) (gr image.Image)

func VHDiv2SSR

func VHDiv2SSR(v, h int) image.YCbCrSubsampleRatio

Translate vertical-horizontal chroma divisors to Go's sub-sampling rate.

Types

type DicomImage added in v0.0.4

type DicomImage struct {
	// contains filtered or unexported fields
}

func (*DicomImage) At added in v0.0.4

func (p *DicomImage) At(x, y int) color.Color

func (*DicomImage) Bounds added in v0.0.4

func (p *DicomImage) Bounds() image.Rectangle

func (*DicomImage) ColorModel added in v0.0.4

func (p *DicomImage) ColorModel() color.Model

func (*DicomImage) PixOffset added in v0.0.4

func (p *DicomImage) PixOffset(x, y int) int

func (*DicomImage) SetWindowLevel added in v0.0.4

func (p *DicomImage) SetWindowLevel(wl int16)

func (*DicomImage) SetWindowWidth added in v0.0.4

func (p *DicomImage) SetWindowWidth(ww int16)

func (*DicomImage) WindowLevel added in v0.0.4

func (p *DicomImage) WindowLevel() int16

func (*DicomImage) WindowWidth added in v0.0.4

func (p *DicomImage) WindowWidth() int16

type Options

type Options struct {
	BPP          int
	Ratio        []float32
	PSNR         []float32
	NResolutions int
}

type SubImage

type SubImage interface {
	SubImage(r image.Rectangle) image.Image
}

Jump to

Keyboard shortcuts

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