<< normalize | Image operations | Geometric transformations >>

scicv >> Image operations > subtract

# subtract

Substract one image from another

### Syntax

    img = sub(img1, img2[, mask[, dtype]])

### Parameters

img1

  Image (Mat).

img2

  Image (Mat).

mask

  Optional mask image (Mat).

dtype

  Optional depth of the output image.

img

  Output image (Mat).

### Description

`sub` computes the difference of two images pixel per pixel.

### Examples

    scicv_Init();

    img1 = imread(getSampleImage("lena.jpg"));
    img2 = new_Mat(size(img1, 'c'), size(img1, 'r'), CV_8UC3, 40);

    img_out = subtract(img1, img2);
    matplot(img_out);

    delete_Mat(img1);
    delete_Mat(img2);
    delete_Mat(img_out);

### See also

- add

Report an issue
<< normalize | Image operations | Geometric transformations >>