Skip to main content

Subtraction

Makes a subtraction between two images.

🖼️ Image options and parameters of subtract method
🎭 Mask options and parameters of subtract method

Method called subtract, as the name suggests, takes another Image(or Mask) and makes a subtraction between each respective bit. It works like this:

let mask = new Mask(3, 3, {
data: new Uint8Array([1, 1, 1, 1, 1, 1, 1, 1, 1]),
});
let mask2 = new Mask(3, 3, {
data: new Uint8Array([1, 1, 1, 0, 0, 0, 0, 0, 1]),
});
mask = mask.subtract(mask2);
// expect mask to equal [0,0,0,1,1,1,1,1,0]
caution

Both masks must have the same size for compatibility reasons. Images must have the same size, channel number and bit depth.

Kinds of images compatible with algorithm

Image propertyWhat it meansPossible values
bitDepthnumber of bits per channel[1,8,16]
componentsnumber of componentsany
alphais alpha channel allowedfalse

Parameters and default values

info

Parameters and options for Images and Masks are the same.

  • other

  • options

Options

PropertyRequiredDefault value
absolutenofalse
info

The method is also available for Masks.