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
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- MATLAB | RGB image to grayscale image conversion
- MATLAB | Converting a Grayscale Image to Binary Image using Thresholding
- Extract bit planes from an Image in Matlab
- Image Processing in MATLAB | Fundamental Operations
- MATLAB | RGB image representation
- MATLAB | Complement colors in a Binary image
- MATLAB | Complement colors in RGB Image
- MATLAB | Complement colors in a Grayscale Image
- MATLAB | Display histogram of a grayscale Image
- LSB based Image steganography using MATLAB
- Display the red, green and blue color planes of a color image in MATLAB
- Image Complement in Matlab
- Image Resizing in Matlab
- Flip image across Secondary Diagonal in MATLAB
- Matlab | Edge Detection of an image without using in-built function
- Matlab | Erosion of an Image
- Matlab | Dilation of an Image
- Create Mirror Image using MATLAB
- How to vertically flip an Image using MATLAB
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.