Read a color image into the workspace.
rgb = imread('yellowlily.jpg');
imshow(rgb)
Display the complement of the image.
c = imcomplement(rgb);
imshow(c)
Each color channel of the resulting image is the complement of the corresponding color channel in the original image. Regions that were dark, such as dirt, become light. In the original image, the leaves appear green, and petals appear yellow because of a mixture of red and green signals. In the complement image, the leaves appear purple because the red and blue signals are larger than the green signal. The flower petals appear blue because the blue signal is larger than the red and green channels.