Skip to main content

Addition

Makes an addition between two images.

🖼️ Image options and parameters of add method

add method, opposed to subtraction, takes another Image and makes an addition between each respective pixel value. It works like this:

let mask = new Image(3, 3, {
data: new Uint8Array([1, 122, 122, 122, 122, 1, 1, 1, 1]),
});
let mask2 = new Image(3, 3, {
data: new Uint8Array([1, 133, 133, 133, 0, 0, 50, 0, 1]),
});
mask = mask.add(mask2);
// expect mask to equal [2,255,255,255,255,122,1,51,2]
caution

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

Kinds of images compatible with algorithm​

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

Parameters and default values​