Module sample

Source
Expand description

Functions and filters for the sampling of pixels.

Structsยง

Filter ๐Ÿ”’
A Representation of a separable filter.
FloatNearest ๐Ÿ”’
ThumbnailSum ๐Ÿ”’
Local struct for keeping track of pixel sums for fast thumbnail averaging

Enumsยง

FilterType
Available Sampling Filters.

Functionsยง

bc_cubic_spline ๐Ÿ”’
blur
Performs a Gaussian blur on the supplied image. sigma is a measure of how much to blur by. Use crate::imageops::fast_blur() for a faster but less accurate version. This method assumes alpha pre-multiplication for images that contain non-constant alpha.
box_kernel ๐Ÿ”’
Calculate the box kernel. Only pixels inside the box should be considered, and those contribute equally. So this method simply returns 1.
catmullrom_kernel ๐Ÿ”’
Calculate the Catmull-Rom cubic spline. Also known as a form of BiCubic sampling in two dimensions.
filter3x3
Perform a 3x3 box filter on the supplied image. kernel is an array of the filter weights of length 9.
gaussian ๐Ÿ”’
The Gaussian Function. r is the standard deviation.
gaussian_kernel ๐Ÿ”’
Calculate the gaussian function with a standard deviation of 0.5
horizontal_sample ๐Ÿ”’
interpolate_bilinear
Linearly sample from an image using coordinates in [0, w-1] and [0, h-1].
interpolate_nearest
Sample from an image using coordinates in [0, w-1] and [0, h-1], taking the nearest pixel.
lanczos ๐Ÿ”’
lanczos3_kernel ๐Ÿ”’
Calculate the lanczos kernel with a window of 3
resize
Resize the supplied image to the specified dimensions. nwidth and nheight are the new dimensions. filter is the sampling filter to use. This method assumes alpha pre-multiplication for images that contain non-constant alpha.
sample_bilinear
Linearly sample from an image using coordinates in [0, 1].
sample_nearest
Sample from an image using coordinates in [0, 1], taking the nearest coordinate.
sinc ๐Ÿ”’
thumbnail
Resize the supplied image to the specific dimensions.
thumbnail_sample_block ๐Ÿ”’
Get a pixel for a thumbnail where the input window encloses at least a full pixel.
thumbnail_sample_fraction_both ๐Ÿ”’
Get a single pixel for a thumbnail where the input window does not enclose any full pixel.
thumbnail_sample_fraction_horizontal ๐Ÿ”’
Get a thumbnail pixel where the input window encloses at least a vertical pixel.
thumbnail_sample_fraction_vertical ๐Ÿ”’
Get a thumbnail pixel where the input window encloses at least a horizontal pixel.
triangle_kernel ๐Ÿ”’
Calculate the triangle function. Also known as BiLinear sampling in two dimensions.
unsharpen
Performs an unsharpen mask on the supplied image. sigma is the amount to blur the image by. threshold is the threshold for minimal brightness change that will be sharpened.
vertical_sample ๐Ÿ”’