| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Image Processing Toolbox |
| Contents | Index |
| Learn more about Image Processing Toolbox |
Z = imsubtract(X,Y)
Z = imsubtract(X,Y) subtracts each element in array Y from the corresponding element in array X and returns the difference in the corresponding element of the output array Z. X and Y are real, nonsparse numeric arrays of the same size and class, or Y is a double scalar. The array returned, Z, has the same size and class as X unless X is logical, in which case Z is double.
If X is an integer array, elements of the output that exceed the range of the integer type are truncated, and fractional values are rounded.
Note On Intel architecture processors, imsubtract can take advantage of the Intel Integrated Performance Primitives (Intel IPP) library, thus accelerating its execution time. The (Intel IPP) library is activated only if array X is of class uint8, int16, or single. |
Subtract two uint8 arrays. Note that negative results are rounded to 0.
X = uint8([ 255 10 75; 44 225 100]);
Y = uint8([ 50 50 50; 50 50 50 ]);
Z = imsubtract(X,Y)
Z =
205 0 25
0 175 50Estimate and subtract the background of an image:
I = imread('rice.png');
background = imopen(I,strel('disk',15));
Ip = imsubtract(I,background);
imshow(Ip,[])Subtract a constant value from an image:
I = imread('rice.png');
Iq = imsubtract(I,50);
figure, imshow(I), figure, imshow(Iq)imabsdiff, imadd, imcomplement, imdivide, imlincomb, immultiply, ippl
![]() | imshow | imtool | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |