SIVP Toolbox
Last update : July, 2006

imsubtract - Subtract two images or subtract a constant from an image

Calling Sequence

imout = imsubtract(im1, im2)



If im1 and im2 are images with the same size and same class, imsubtract subtracts each element in im2 from the corresponding one in im1. If im2 is a double scalar, the element in imout is the difference of the corresponding one in im1 with the double scalar. imout has the same size and class with im1.

If im1 is an integer matrix, the elements in the output matrix imout that exceed the range of the integer type will be truncated.

Supported classes: INT8, UINT8, INT16, UINT16, INT32, DOUBLE.


    im1 = imread('lena.png');
    im2 = imread('peppers.png');
    ims1 = imsubtract(im1, im2);
    ims2 = imsubtract(im1, 50);


Shiqi Yu <shiqi.yu[at]>


The latest version of SIVP can be found at

See Also

imabsdiff,  imadd,  immultiply,  imdivide,  imcomplement,  imlincomb,