Skip to main content

Subtraction

Makes a subtraction between two images.

Check 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.

Parameters and default values

  • other

  • options

Options

PropertyRequiredDefault value
absolutenofalse