| Image Processing Toolbox™ | ![]() |
Z = imabsdiff(X,Y)
Z = imabsdiff(X,Y) subtracts each element in array Y from the corresponding element in array X and returns the absolute difference in the corresponding element of the output array Z. X and Y are real, nonsparse numeric arrays with the same class and size. Z has the same class and size as X and Y. If X and Y are integer arrays, elements in the output that exceed the range of the integer type are truncated.
If X and Y are double arrays, you can use the expression abs(X-Y) instead of this function.
Note On Intel architecture processors, imabsdiff can take advantage of the Intel Performance Primitives Library (IPPL), thus accelerating its execution time. IPPL is activated only if arrays X, Y, and Z are of class logical, uint8, or single, and are of the same class. |
Calculate the absolute difference between two uint8 arrays. Note that the absolute value prevents negative values from being rounded to zero in the result, as they are with imsubtract.
X = uint8([ 255 10 75; 44 225 100]);
Y = uint8([ 50 50 50; 50 50 50 ]);
Z = imabsdiff(X,Y)
Z =
205 40 25
6 175 50Display the absolute difference between a filtered image and the original.
I = imread('cameraman.tif');
J = uint8(filter2(fspecial('gaussian'), I));
K = imabsdiff(I,J);
imshow(K,[]) % [] = scale data automaticallyimadd, imcomplement, imdivide, imlincomb, immultiply, imsubtract, ippl
![]() | im2uint8 | imadd | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |