Image Processing Toolbox User's Guide |
Syntax
Description
IM2 = imcomplement(IM)
computes the complement of the image IM
. IM
can be a binary, intensity, or RGB image. IM2
has the same class and size as IM
.
In the complement of a binary image, zeros become ones and ones become zeros; black and white are reversed. In the complement of an intensity or RGB image, each pixel value is subtracted from the maximum pixel value supported by the class (or 1.0 for double-precision images) and the difference is used as the pixel value in the output image. In the output image, dark areas become lighter and light areas become darker.
If IM
is an intensity or RGB image of class double
, you can use the expression 1-IM
instead of this function. If IM
is a binary image, you can use the expression ~IM
instead of this function.
Examples
Create the complement of a uint8
array.
Reverse black and white in a binary image.
bw = imread('text.png'); bw2 = imcomplement(bw); subplot(1,2,1),imshow(bw) subplot(1,2,2),imshow(bw2)
Create the complement of an intensity image.
See Also
imabsdiff
, imadd
, imdivide
, imlincomb
, immultiply
, imsubtract
imclose | imcontour |
© 1994-2005 The MathWorks, Inc.