resize

package
v0.0.0-...-d61e921 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResizeGray

func ResizeGray(img *image.Gray, fx float64, fy float64, interpolation Interpolation) (*image.Gray, error)

ResizeGray resizes an grayscale (Gray) image. Input parameters: rbga imaga which will be resized; fx, fy scaling factors, their value has to be a positive float, the new size of the image will be computed as originalWidth * fx and originalHeight * fy; interpolation method, currently the following methods are supported: InterNearest, InterLinear, InterCatmullRom, InterLanczos. Example of usage:

res, err := resize.ResizeGray(img, 2.5, 3.5, resize.InterLinear)

func ResizeRGBA

func ResizeRGBA(img *image.RGBA, fx float64, fy float64, interpolation Interpolation) (*image.RGBA, error)

ResizeRGBA resizes an RGBA image. Input parameters: rbga imaga which will be resized; fx, fy scaling factors, their value has to be a positive float, the new size of the image will be computed as originalWidth * fx and originalHeight * fy; interpolation method, currently the following methods are supported: InterNearest, InterLinear, InterCatmullRom, InterLanczos. Example of usage:

res, err := resize.ResizeRGBA(img, 2.5, 3.5, resize.InterLinear)

Types

type CatmullRom

type CatmullRom struct{}

CatmullRom - Struct for Catmull-Rom filter

func NewCatmullRom

func NewCatmullRom() *CatmullRom

NewCatmullRom creates a new Catmull-Rom filter

func (*CatmullRom) GetS

func (r *CatmullRom) GetS() float64

GetS returns the support value for Catmull-Rom filter

func (*CatmullRom) Interpolate

func (r *CatmullRom) Interpolate(x float64) float64

Interpolate returns the coefficient for x value using Catmull-Rom interpolation

type Filter

type Filter interface {
	Interpolate(float64) float64
	GetS() float64
}

Filter - Interface for resampling filters

type Interpolation

type Interpolation int

Interpolation method types

const (
	// InterNearest - takes the nearest pixel.
	InterNearest Interpolation = iota
	// InterLinear - Linear interpolation between two pixels. More info: https://en.wikipedia.org/wiki/Linear_interpolation
	InterLinear
	// InterCatmullRom - Catmull-Rom resampling. More info: https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline
	InterCatmullRom
	// InterLanczos - Lanczos resampling. More info: https://en.wikipedia.org/wiki/Lanczos_resampling
	InterLanczos
)

type Lanczos

type Lanczos struct{}

Lanczos - struct for Lanczos filter

func NewLanczos

func NewLanczos() *Lanczos

NewLanczos creates a new Lanczos filter

func (*Lanczos) GetS

func (r *Lanczos) GetS() float64

GetS returns the support value for Lanczos filter

func (*Lanczos) Interpolate

func (r *Lanczos) Interpolate(x float64) float64

Interpolate returns the coefficient for x value using Lanczos interpolation

type Linear

type Linear struct{}

Linear - Struct for Linear filter

func NewLinear

func NewLinear() *Linear

NewLinear creates a new Linear filter

func (*Linear) GetS

func (r *Linear) GetS() float64

GetS returns the support value for Linear filter

func (*Linear) Interpolate

func (r *Linear) Interpolate(x float64) float64

Interpolate returns the coefficient for x value using Linear interpolation

Jump to

Keyboard shortcuts

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