The negative of an image is achieved by replacing the intensity ‘i’ in the original image by ‘i-1’, i.e. the darkest pixels will become the brightest and the brightest pixels will become the darkest. Image negative is produced by subtracting each pixel from the maximum intensity value.
For example in an 8-bit grayscale image, the max intensity value is 255, thus each pixel is subtracted from 255 to produce the output image.
The transformation function used in image negative is :
s = T(r) = (L – 1) – r Where L - 1 is the max intensity value, s is the output pixel value and r is the input pixel value
- Read RGB color image into the MATLAB environment using Matlab inbuilt function
- Calculate the levels of the image, for example an 8-bit image has 256 levels
- Use the formula stated above on every pixel of the image to get corresponding negative pixel value.
- Convert each RGB pixel value at location (i, j) to its negative image values and assign it to the corresponding location (i, j) of another matrix
- Display the negative image using Matlab in-built