Negative Image

samir khanal
2 min readMar 25, 2020

A negative of an image is an image where its lightest areas appear as darkest and the darkest areas appear as lightest.

The appearance change from lightest to darkest and darkest to lightest is basically done in gray scale image and refers to the change of pixel intensity values from highest to lowest and lowest to highest.

In case of colour image, different colour is represented as negative of different colours according to their intensity values.

Let us take an 8-bit image with intensity range of 0–255.

For gray image(or monochrome image), we can convert it into its negative form by simply subtracting the current pixel intensity value from 255(maximum intensity value for 8-bit image).

Mathematically,

f(x,y) = 255-f(x,y)

where, f(x,y) gives the pixel intensity value at position (x,y).

For colour image, we can convert it into its negative form by simply subtracting the RGB intensity value from 255.

Mathematically,

R = 255-R

G = 255 -G

B = 255 -B

Here is a sample python code for converting to negative image and some output images.

sample python code for converting to negative image
(left) sample colour image (right) negative of given colour image
(left) sample colour image of Avengers End game (right) negative of given colour image

--

--