Documentation ¶
Overview ¶
Package imgutil implements a set of image processing utilities. Funcs in this package perform modifications in-place, except where otherwise noted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // CatmullRom is the Catmull-Rom kernel. It is very slow, but usually gives // very high quality results. // // It is an instance of the more general cubic BC-spline kernel with parameters // B=0 and C=0.5. See Mitchell and Netravali, "Reconstruction Filters in // Computer Graphics", Computer Graphics, Vol. 22, No. 4, pp. 221-228. CatmullRom = &Kernel{2, func(t float64) float64 { if t < 1 { return (1.5*t-2.5)*t*t + 1 } return ((-0.5*t+2.5)*t-4)*t + 2 }} )
Functions ¶
func AdjustGamma ¶
AdjustGamma applies gamma adjustments.
Gamma value of 1 doesn't change the image, < 1 darkens and >1 brightens it.
func AutoContrast ¶
AutoContrast applies histogram normalization to the image, ignoring specified cutoff % highest and lowest values.
This implementation is taken from Pillow's ImageOps.autocontrast method. See: https://pillow.readthedocs.io/en/stable/_modules/PIL/ImageOps.html#autocontrast
func FitRect ¶ added in v0.1.1
FitRect scales an image.Rectangle to fit into a bounding box of x by y without changing the aspect ratio.
Types ¶
type ImagePool ¶ added in v0.1.2
type ImagePool struct {
// contains filtered or unexported fields
}
ImagePool maintains a sync.Pool of pixel arrays for each image resolution gotten from it.
func NewImagePool ¶ added in v0.1.2
func NewImagePool() *ImagePool
NewImagePool creates an ImagePool.
func (*ImagePool) Get ¶ added in v0.1.2
Get gets a grayscale image of specified width and height with pixel slice taken from the pool.
func (*ImagePool) GetFromImage ¶ added in v0.1.2
GetFromImage converts an image into a grayscale image with pixel slice taken from the pool.
type Kernel ¶ added in v0.1.1
type Kernel struct { // Support is the kernel support and must be >= 0. At(t) is assumed to be // zero when t >= Support. Support float64 // At is the kernel function. It will only be called with t in the // range [0, Support). At func(t float64) float64 }
Kernel is an interpolator that blends source pixels weighted by a symmetric kernel function.
type Scaler ¶ added in v0.1.1
Scaler scales the source image to the destination image.
func NewCacheScaler ¶ added in v0.1.2
NewCacheScaler creates, caches and reuses kernel scalers optimized for each unique combination of destination and source width and height. It is mostly useful when scaling a large quantity of images in a few fixed sizes.