View Source Image.Math (image v0.2.0)

Implements math operators for images, delegating to the Kernel functions in the cases where the parameters do not include Vix.Vips.Image.t/0.

To override the standard operations in a function or module, add use Image.Math.

To maximise readability and clarity it is recommended that use Image.Math be added to only those functions that require it.

example

Example

defmodule MyModule do
  # Not recommended
  use Image.Math

  def my_function(%Vix.Vips.Image{} = image) do
    # Recommended
    use Image.Math

    # Increase the all bands by 20%
    brigher = image * 1.2

    # Or adjust only green by 20%
    bright_green = image * [1, 1.2, 1]
  end
end

Link to this section Summary

Functions

Matrix inequality of two images or one image and a constant or vector.

Matrix exponent of two images or one image and a constant or vector.

Matrix multiplation of two images or one image and a constant or vector.

Matrix addition of two images or one image and a constant or vector.

Matrix subtraction of two images or one image and a constant or vector.

Matrix division of two images or one image and a constant or vector.

Matrix less than of two images or one image and a constant or vector.

Matrix less than or equal of two images or one image and a constant or vector.

Matrix equality of two images or one image and a constant or vector.

Matrix greater than of two images or one image and a constant or vector.

Matrix greater than or equal of two images or one image and a constant or vector.

Guards if a given value might be reasonably interpreted as a pixel.

Return the image maximum.

Return the image minimum.

Link to this section Functions

Matrix inequality of two images or one image and a constant or vector.

Delegates to Kernel.!=/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix exponent of two images or one image and a constant or vector.

Delegates to Kernel.**/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix multiplation of two images or one image and a constant or vector.

Delegates to Kernel.*/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix addition of two images or one image and a constant or vector.

Delegates to Kernel.+/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix subtraction of two images or one image and a constant or vector.

Delegates to Kernel.-/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix division of two images or one image and a constant or vector.

Delegates to Kernel.//2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix less than of two images or one image and a constant or vector.

Delegates to Kernel.</2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix less than or equal of two images or one image and a constant or vector.

Delegates to Kernel.<=/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix equality of two images or one image and a constant or vector.

Delegates to Kernel.==/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix greater than of two images or one image and a constant or vector.

Delegates to Kernel.>/2 if none of the parameters is a Vix.Vips.Image.t/0.

Matrix greater than or equal of two images or one image and a constant or vector.

Delegates to Kernel.>=/2 if none of the parameters is a Vix.Vips.Image.t/0.

@spec add!(Vix.Vips.Image.t(), Image.pixel()) :: Vix.Vips.Image.t() | no_return()
@spec add!(Image.pixel(), Vix.Vips.Image.t()) :: Vix.Vips.Image.t() | no_return()
@spec add!(number(), number()) :: number() | no_return()
@spec add(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec add(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec add(Vix.Vips.Image.t(), [number()]) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec add(number(), number()) :: {:ok, number()}
@spec cos(Vix.Vips.Image.t()) :: {:ok, Vix.Vips.Image.t()}
@spec cos(number()) :: {:ok, number()}
@spec divide!(Vix.Vips.Image.t(), Image.pixel()) :: Vix.Vips.Image.t() | no_return()
@spec divide!(number(), number()) :: number() | no_return()
@spec divide(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec divide(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec divide(Vix.Vips.Image.t(), [number()]) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec divide(number(), number()) :: {:ok, number()}
@spec equal!(Vix.Vips.Image.t(), Image.pixel()) :: Vix.Vips.Image.t() | no_return()
@spec equal!(number(), number()) :: number() | no_return()
@spec equal(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec equal(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Link to this function

greater_than!(image, value)

View Source
@spec greater_than!(Vix.Vips.Image.t(), Vix.Vips.Image.t() | Image.pixel()) ::
  Vix.Vips.Image.t() | no_return()
@spec greater_than!(number(), number()) :: number() | no_return()
Link to this function

greater_than(image, other)

View Source
@spec greater_than(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec greater_than(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Link to this function

greater_than_or_equal!(image, value)

View Source
@spec greater_than_or_equal!(Vix.Vips.Image.t(), Image.pixel()) ::
  Vix.Vips.Image.t() | no_return()
@spec greater_than_or_equal!(number(), number()) :: number() | no_return()
Link to this function

greater_than_or_equal(image, other)

View Source
@spec greater_than_or_equal(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec greater_than_or_equal(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Link to this macro

is_pixel(value)

View Source (macro)

Guards if a given value might be reasonably interpreted as a pixel.

Link to this function

less_than!(image, value)

View Source
@spec less_than!(Vix.Vips.Image.t(), Vix.Vips.Image.t() | Image.pixel()) ::
  Vix.Vips.Image.t() | no_return()
@spec less_than!(number(), number()) :: number() | no_return()
@spec less_than(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec less_than(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Link to this function

less_than_or_equal!(image, value)

View Source
@spec less_than_or_equal!(Vix.Vips.Image.t(), Vix.Vips.Image.t() | Image.pixel()) ::
  Vix.Vips.Image.t() | no_return()
@spec less_than_or_equal!(number(), number()) :: number() | no_return()
Link to this function

less_than_or_equal(image, other)

View Source
@spec less_than_or_equal(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec less_than_or_equal(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
Link to this function

maxpos(image, options \\ [])

View Source
@spec maxpos(Vix.Vips.Image.t(), Keyword.t()) ::
  {:ok, maximum :: float(), x_positiom :: integer(), y_position :: integer()}

Return the image maximum.

arguments

Arguments

options

Options

  • :size is the number of maximums to find. The default is 10.

returns

Returns

  • {:ok, maximum, x_position, y_position}
Link to this function

minpos(image, options \\ [])

View Source
@spec minpos(Vix.Vips.Image.t(), Keyword.t()) ::
  {:ok, minimium :: float(), x_positiom :: integer(), y_position :: integer()}

Return the image minimum.

arguments

Arguments

options

Options

  • :size is the number of minimums to find. The default is 10.

returns

Returns

  • {:ok, minimum, x_position, y_position}
@spec multiply!(Vix.Vips.Image.t(), Image.pixel()) :: Vix.Vips.Image.t() | no_return()
@spec multiply!(Image.pixel(), Vix.Vips.Image.t()) :: Vix.Vips.Image.t() | no_return()
@spec multiply!(number(), number()) :: number() | no_return()
@spec multiply(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec multiply(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec multiply(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec multiply(number(), number()) :: {:ok, number()}
Link to this function

not_equal!(image, value)

View Source
@spec not_equal!(Vix.Vips.Image.t(), Image.pixel()) ::
  Vix.Vips.Image.t() | no_return()
@spec not_equal!(number(), number()) :: number() | no_return()
@spec not_equal(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec not_equal(Vix.Vips.Image.t(), Image.pixel()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec pow!(Vix.Vips.Image.t(), number()) :: Vix.Vips.Image.t() | no_return()
@spec pow!(number(), number()) :: number() | no_return()
@spec pow(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec pow(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec pow(number(), number()) :: {:ok, number()}
@spec sin(Vix.Vips.Image.t()) :: {:ok, Vix.Vips.Image.t()}
@spec sin(number()) :: {:ok, number()}
@spec subtract!(Vix.Vips.Image.t(), Image.pixel()) :: Vix.Vips.Image.t() | no_return()
@spec subtract!(Image.pixel(), Vix.Vips.Image.t()) :: Vix.Vips.Image.t() | no_return()
@spec subtract!(number(), number()) :: number() | no_return()
@spec subtract(Vix.Vips.Image.t(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec subtract(Vix.Vips.Image.t(), number()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec subtract(Vix.Vips.Image.t(), [number()]) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec subtract(number(), Vix.Vips.Image.t()) ::
  {:ok, Vix.Vips.Image.t()} | {:error, Image.error_message()}
@spec subtract(number(), number()) :: {:ok, number()}