Documentation ¶
Overview ¶
Package resize implements various image resizing methods.
The package works with the Image interface described in the image package. Various interpolation methods are provided and multiple processors may be utilized in the computations.
Example:
imgResized := resize.Resize(1000, 0, imgOld, resize.MitchellNetravali)
Index ¶
- func Gaussian(sigma float64, in int) float64
- func GaussianSmooth(srcImg image.Image, sigma float64, radius int) image.Image
- func Resize(width, height int, img image.Image, interp InterpolationFunction) image.Image
- func Thumbnail(maxWidth, maxHeight int, img image.Image, interp InterpolationFunction) image.Image
- type InterpolationFunction
- type Ycc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GaussianSmooth ¶
func Resize ¶
Resize scales an image to new width and height using the interpolation function interp. A new image with the given dimensions will be returned. If one of the parameters width or height is set to 0, its size will be calculated so that the aspect ratio is that of the originating image. The resizing algorithm uses channels for parallel computation.
Types ¶
type InterpolationFunction ¶
type InterpolationFunction int
An InterpolationFunction provides the parameters that describe an interpolation kernel. It returns the number of samples to take and the kernel function to use for sampling.
const ( // Nearest-neighbor interpolation NearestNeighbor InterpolationFunction = iota // Bilinear interpolation Bilinear // Bicubic interpolation (with cubic hermite spline) Bicubic // Mitchell-Netravali interpolation MitchellNetravali // Lanczos interpolation (a=2) Lanczos2 // Lanczos interpolation (a=3) Lanczos3 )
InterpolationFunction constants
type Ycc ¶
type Ycc struct { // Pix holds the image's pixels, in Y, Cb, Cr order. The pixel at // (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*3]. Pix []uint8 // Stride is the Pix stride (in bytes) between vertically adjacent pixels. Stride int // Rect is the image's bounds. Rect image.Rectangle // SubsampleRatio is the subsample ratio of the original YCbCr image. SubsampleRatio image.YCbCrSubsampleRatio }
Ycc is an in memory YCbCr image. The Y, Cb and Cr samples are held in a single slice to increase resizing performance.
func ImageYCbCrToYcc ¶
ImageYCbCrToYcc converts a YCbCr image to a Ycc image for resizing.
func (*Ycc) ColorModel ¶
func (*Ycc) PixOffset ¶
PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).