View Source Vix.Operator (vix v0.31.1)

Provides implementation of basic math operators for Vix Image.

Useful to improve the readability of complex Image processing operation pipelines.

def foo do
  use Vix.Operator

  black = Operation.black!(100, 100, bands: 3)
  white = Operation.invert!(black)

  white == white + black
  grey = black + 125  # same as [125]
  grey = black + [125] # same as [125, 125, 125], since the image contains 3 bands
  grey = black + [125, 125, 125]
end

Summary

Functions

Perform multiplication operation of an image and a number, an array or an another image.

Perform addition operation of an image and a number, an array or an another image.

Perform subtraction operation of an image and a number, an array or an another image.

Perform division operation of an image and a number, an array or an another image.

Functions

Perform multiplication operation of an image and a number, an array or an another image.

  • if argument is a number or a list of only one number, then the same number is used for all image bands for the operation. Example img * 2, img + [2]
  • if array size matches image bands, then each array element is added to respective band
  • if array size is more than image bands and image only contains one band then the output will be a multi band image with each array element mapping to one band
  • if argument is an image, then Vix.Vips.Operation.multiply!/2 operation will be performed

When none of the argument is an image then delegates to Kernel.*/2

Perform addition operation of an image and a number, an array or an another image.

  • if argument is a number or a list of only one number, then the same number is used for all image bands for the operation. Example img + 255, img + [255]
  • if array size matches image bands, then each array element is added to respective band. Example red = Operation.black!(100, 100, bands: 3) + [125, 0, 0]
  • if array size is more than image bands and image only contains one band then the output will be a multi band image with each array element mapping to one band
  • if argument is an image, then Vix.Vips.Operation.add!/2 operation will be performed

When none of the argument is an image then delegates to Kernel.+/2

Perform subtraction operation of an image and a number, an array or an another image.

  • if argument is a number or a list of only one number, then the same number is used for all image bands for the operation. Example img - 125, img - [125]
  • if array size matches image bands, then each array element is added to respective band
  • if array size is more than image bands and image only contains one band then the output will be a multi band image with each array element mapping to one band
  • if argument is an image, then Vix.Vips.Operation.subtract!/2 operation will be performed

When none of the argument is an image then delegates to Kernel.-/2

Perform division operation of an image and a number, an array or an another image.

  • if argument is a number or a list of only one number, then the same number is used for all image bands for the operation. Example img / 2, img / [2]
  • if array size matches image bands, then each array element is added to respective band
  • if array size is more than image bands and image only contains one band then the output will be a multi band image with each array element mapping to one band
  • if argument is an image, then Vix.Vips.Operation.divide!/2 operation will be performed

When none of the argument is an image then delegates to Kernel.//2