Addition
Makes an addition between two images.
Check 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.