IM2 = imcomplement(IM)
gpuarrayIM2 = imcomplement(gpuarrayIM)
IM2 = imcomplement(IM) computes the complement
of the image
IM can be a
binary, grayscale, or RGB image.
IM2 has the same
class and size as
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.
gpuarrayIM2 = imcomplement(gpuarrayIM) computes
the complement of the image on a GPU. The input image
the return values are gpuArrays.
a gpuArray with the same underlying class and size as
This syntax requires the Parallel Computing Toolbox™.
X = uint8([ 255 10 75; 44 225 100]); X2 = imcomplement(X)
X2 = 2×3 uint8 matrix 0 245 180 211 30 155
bw = imread('text.png'); bw2 = imcomplement(bw); imshowpair(bw,bw2,'montage')
I = imread('cameraman.tif'); J = imcomplement(I); imshowpair(I,J,'montage')
I = imread('glass.png'); J = imcomplement(I); imshow(I), figure, imshow(J)
IM is a grayscale or RGB image
double, you can use the expression
of this function. If
IM is a binary image, you
can use the expression
~IM instead of this function.
Usage notes and limitations:
This function supports the generation of C code using MATLAB® Coder™. For more information, see Code Generation for Image Processing.
imcomplement does not support