Imger

Library including imger image filters.


Source: pkg/lua/lib/imger.go | Import: imger

Functions


gray_add

gray_add(img1, img2)

Result is stored in img1.

Arguments

  • img1 int<collection.IMAGE> - First image.
  • img2 int<collection.IMAGE> - Second image.
gray_add_weighted

gray_add_weighted(img1, img2, weight1, weight2)

Result is stored in img1.

Arguments

  • img1 int<collection.IMAGE> - First image.
  • img2 int<collection.IMAGE> - Second image.
  • weight1 float - Weight of the first image.
  • weight2 float - Weight of the second image.
gray_add_scalar

gray_add_scalar(img, value)

Arguments

  • img int<collection.IMAGE>
  • value int
blur_box

blur_box(img, ksize, anchor, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • ksize struct<image.Point>
  • anchor struct<image.Point> - Point inside of kernel.
  • border int<imger.Border>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
blur_box_xy

blur_box_xy(img, kwidth, kheight, ax, ay, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • kwidth int
  • kheight int
  • ax int - Anchor x inside of kernel.
  • ay int - Anchor y inside of kernel.
  • border int<imger.Border>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
blur_gaussian

blur_gaussian(img, radius, sigma, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • radius float
  • sigma float
  • border int<imger.Border>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
kernel

kernel(width, height, content) -> struct<imger.Kernel>

Arguments

  • width int - Width of the kernel.
  • height int - Height of the kernel.
  • content [][]float - Kernel content.
Return Values

  • struct<imger.Kernel>
kernel_zero

kernel_zero(width, height) -> struct<imger.Kernel>

Arguments

  • width int - Width of the kernel.
  • height int - Height of the kernel.
Return Values

  • struct<imger.Kernel>
kernel_flat

kernel_flat(width, height, content_flat) -> struct<imger.Kernel>

Arguments

  • width int - Width of the kernel.
  • height int - Height of the kernel.
  • content_flat []float - Kernel content as a flat array. The length of the array must be width * height. Should be row-major order.
Return Values

  • struct<imger.Kernel>
convolve

convolve(img, kernel, anchor, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • kernel struct<imger.Kernel>
  • anchor struct<image.Point> - Point inside of kernel.
  • border int<imger.Border>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
convolve_xy

convolve_xy(img, kernel, ax, ay, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • kernel struct<imger.Kernel>
  • ax int - Anchor x inside of kernel.
  • ay int - Anchor y inside of kernel.
  • border int<imger.Border>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
edge_canny

edge_canny(img, lower, upper, ksize, name, encoding, gray?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • lower float - Lower threshold.
  • upper float - Upper threshold.
  • ksize int - Size of the kernel.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.GRAY color model.
edge_canny_inplace

edge_canny_inplace(img, lower, upper, ksize, gray?)

Arguments

  • img int<collection.IMAGE>
  • lower float - Lower threshold.
  • upper float - Upper threshold.
  • ksize int - Size of the kernel.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
edge_sobel

edge_sobel(img, name, encoding, border, gray?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.GRAY color model.
edge_sobel_inplace

edge_sobel_inplace(img, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
edge_sobel_horizontal

edge_sobel_horizontal(img, name, encoding, border, gray?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.GRAY color model.
edge_sobel_horizontal_inplace

edge_sobel_horizontal_inplace(img, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
edge_sobel_vertical

edge_sobel_vertical(img, name, encoding, border, gray?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.GRAY color model.
edge_sobel_vertical_inplace

edge_sobel_vertical_inplace(img, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
edge_laplacian

edge_laplacian(img, kernel, name, encoding, border, gray?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • kernel int<imger.LaplacianKernel> - Laplacian kernel.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.GRAY color model.
edge_laplacian_inplace

edge_laplacian_inplace(img, kernel, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • kernel int<imger.LaplacianKernel> - Laplacian kernel.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
emboss

emboss(img, gray?)

Arguments

  • img int<collection.IMAGE>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
invert

invert(img, gray?)

Arguments

  • img int<collection.IMAGE>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
pixelate

pixelate(img, factor, gray?)

Arguments

  • img int<collection.IMAGE>
  • factor float - Pixelation factor.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
sharpen

sharpen(img, gray?)

Arguments

  • img int<collection.IMAGE>
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
sepia

sepia(img)

Arguments

  • img int<collection.IMAGE>
gradient_linear

gradient_linear(size, startColor, endColor, direction, name, encoding) -> int<collection.IMAGE>

Arguments

  • size struct<image.Point> - Size of the gradient.
  • startColor struct<image.Color> - Start color of the gradient.
  • endColor struct<image.Color> - End color of the gradient.
  • direction int<imger.Direction> - Direction of the gradient.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.RGBA color model.
gradient_linear_xy

gradient_linear_xy(width, height, startColor, endColor, direction, name, encoding) -> int<collection.IMAGE>

Arguments

  • width int - Width of the gradient.
  • height int - Height of the gradient.
  • startColor struct<image.Color> - Start color of the gradient.
  • endColor struct<image.Color> - End color of the gradient.
  • direction int<imger.Direction> - Direction of the gradient.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.RGBA color model.
gradient_sigmoidal

gradient_sigmoidal(size, startColor, endColor, direction, name, encoding) -> int<collection.IMAGE>

Arguments

  • size struct<image.Point> - Size of the gradient.
  • startColor struct<image.Color> - Start color of the gradient.
  • endColor struct<image.Color> - End color of the gradient.
  • direction int<imger.Direction> - Direction of the gradient.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.RGBA color model.
gradient_sigmoidal_xy

gradient_sigmoidal_xy(width, height, startColor, endColor, direction, name, encoding) -> int<collection.IMAGE>

Arguments

  • width int - Width of the gradient.
  • height int - Height of the gradient.
  • startColor struct<image.Color> - Start color of the gradient.
  • endColor struct<image.Color> - End color of the gradient.
  • direction int<imger.Direction> - Direction of the gradient.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
Return Values

  • int<collection.IMAGE> - The resulting image will be in the image.RGBA color model.
grayscale

grayscale(img, name, encoding, to16?) -> int<collection.IMAGE>

Arguments

  • img int<collection.IMAGE>
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • to16 bool - If true, the image is converted to 16-bit grayscale, otherwise it is converted to 8-bit grayscale.
Return Values

  • int<collection.IMAGE>
grayscale_inplace

grayscale_inplace(img, to16?)

Arguments

  • img int<collection.IMAGE>
  • to16 bool - If true, the image is converted to 16-bit grayscale, otherwise it is converted to 8-bit grayscale.
padding

padding(img, ksize, anchor, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • ksize struct<image.Point> - Size of the kernel.
  • anchor struct<image.Point> - Anchor point of the kernel.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
padding_xy

padding_xy(img, kwidth, kheight, ax, ay, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • kwidth int - Width of the kernel.
  • kheight int - Height of the kernel.
  • ax int - X coordinate of the anchor point.
  • ay int - Y coordinate of the anchor point.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
padding_size

padding_size(img, top, bottom, left, right, border, gray?)

Arguments

  • img int<collection.IMAGE>
  • top int - Top padding.
  • bottom int - Bottom padding.
  • left int - Left padding.
  • right int - Right padding.
  • border int<imger.Border> - Border type.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
threshold

threshold(img, t, method, to16?)

Arguments

  • img int<collection.IMAGE>
  • t int - Threshold value, either an uint8 or uint16 value.
  • method int<imger.Threshold> - Threshold method.
  • to16 bool - If true, the image is converted to 16-bit grayscale, otherwise it is converted to 8-bit grayscale.
threshold_otsu

threshold_otsu(img, method)

Arguments

  • img int<collection.IMAGE>
  • method int<imger.Threshold> - Threshold method.
rotate

rotate(img, angle, anchor, resizeToFit, gray?)

Arguments

  • img int<collection.IMAGE>
  • angle float - Angle of rotation in degrees, counter-clockwise.
  • anchor struct<image.Point> - Anchor point of rotation.
  • resizeToFit bool - If true, the image is resized to fit the rotated image.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
rotate_xy

rotate_xy(img, angle, ax, ay, resizeToFit, gray?)

Arguments

  • img int<collection.IMAGE>
  • angle float - Angle of rotation in degrees, counter-clockwise.
  • ax int - X coordinate of the anchor point.
  • ay int - Y coordinate of the anchor point.
  • resizeToFit bool - If true, the image is resized to fit the rotated image.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
resize

resize(img, scalex, scaley, inter, gray?)

Arguments

  • img int<collection.IMAGE>
  • scalex float - Scale factor along the horizontal axis.
  • scaley float - Scale factor along the vertical axis.
  • inter int<imger.Interpolation> - Interpolation method.
  • gray bool - If true, the image is converted to gray before applying the filter, otherwise it is converted to RGBA.
histogram_draw

histogram_draw(img, scale, name, encoding, gray?) -> int<collection.IMAGE>

Size is (256*scale.x, 256*scale.y).

Arguments

  • img int<collection.IMAGE>
  • scale struct<image.Point> - Scale of the histogram.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • gray bool
Return Values

  • int<collection.IMAGE>
histogram_draw_xy

histogram_draw_xy(img, scalex, scaley, name, encoding, gray?) -> int<collection.IMAGE>

Size is (256*scalex, 256*scaley).

Arguments

  • img int<collection.IMAGE>
  • scalex int - Scale of the histogram along the horizontal axis.
  • scaley int - Scale of the histogram along the vertical axis.
  • name string - Name of the image.
  • encoding int<image.Encoding> - Encoding of the image.
  • gray bool
Return Values

  • int<collection.IMAGE>
histogram_draw_inplace

histogram_draw_inplace(img, scale, gray?)

Size is (256*scale.x, 256*scale.y).

Arguments

  • img int<collection.IMAGE>
  • scale struct<image.Point> - Scale of the histogram.
  • gray bool
histogram_draw_inplace_xy

histogram_draw_inplace_xy(img, scalex, scaley, gray?)

Size is (256*scalex, 256*scaley).

Arguments

  • img int<collection.IMAGE>
  • scalex int - Scale of the histogram along the horizontal axis.
  • scaley int - Scale of the histogram along the vertical axis.
  • gray bool
histogram_gray

histogram_gray(img, max, removeZero?) -> []int

@blocking
Arguments

  • img int<collection.IMAGE>
  • max int - Maximum value of the histogram.
  • removeZero bool - If true, the zero value is removed from the histogram.
Return Values

  • []int - Length is 256.
histogram_rgb

histogram_rgb(img, max, removeZero?) -> []int, []int, []int

@blocking
Arguments

  • img int<collection.IMAGE>
  • max int - Maximum value of the histogram.
  • removeZero bool - If true, the zero value is removed from the histogram.
Return Values

  • []int - Histogram of the red channel, length is 256.
  • []int - Histogram of the green channel, length is 256.
  • []int - Histogram of the blue channel, length is 256.
histogram_red

histogram_red(img, max, removeZero?) -> []int

@blocking
Arguments

  • img int<collection.IMAGE>
  • max int - Maximum value of the histogram.
  • removeZero bool - If true, the zero value is removed from the histogram.
Return Values

  • []int - Length is 256.
histogram_green

histogram_green(img, max, removeZero?) -> []int

@blocking
Arguments

  • img int<collection.IMAGE>
  • max int - Maximum value of the histogram.
  • removeZero bool - If true, the zero value is removed from the histogram.
Return Values

  • []int - Length is 256.
histogram_blue

histogram_blue(img, max, removeZero?) -> []int

@blocking
Arguments

  • img int<collection.IMAGE>
  • max int - Maximum value of the histogram.
  • removeZero bool - If true, the zero value is removed from the histogram.
Return Values

  • []int - Length is 256.

Constants


Border
  • BORDER_CONSTANT
  • BORDER_REPLICATE
  • BORDER_REFLECT
LaplacianKernel
  • LAPLACIAN_K4
  • LAPLACIAN_K8
Direction
  • DIR_HORIZONTAL
  • DIR_VERTICAL
Threshold
  • THRESHOLD_BINARY
  • THRESHOLD_BINARYINV
  • THRESHOLD_TRUNC
  • THRESHOLD_TOZERO
  • THRESHOLD_TOZEROINV
Interpolation
  • INTER_NEAREST
  • INTER_LINEAR
  • INTER_CATMULLROM
  • INTER_LANCZOS

Structs


Kernel

Properties

  • width int - Width of the kernel.
  • height int - Height of the kernel.
  • content [][]float - Kernel content.
Methods

center

center() -> struct<image.Point>


Returns the center of the kernel, rounded down.

center_xy

center_xy() -> int, int


Returns the center of the kernel, rounded down.

sum

sum() -> float


Returns the sum of all elements in the kernel.

sum_abs

sum_abs() -> float


Returns the sum of the absolute values of all elements in the kernel.

size

size() -> struct<image.Point>


Returns the size of the kernel as a point.

at

at(x int, y int) -> float


Returns the value at the given position, or nil if out of bounds. Uses 0-based indexing, set directly to the kernel content for 1-based indexing.

set

set(self, x int, y int, value float) -> self


Sets the value at the given position. Uses 0-based indexing, set directly to the kernel content for 1-based indexing.

normalize

normalize(self) -> self


Normalizes the kernel.

normalize_set

normalize_set(self, normalize bool) -> self


Sets the normalize flag of the kernel, this normalization is only run when the kernel is built.