Inverse-Effect
Inverting an image or Negative transformation of an image is a very basic method of image processing
in which the brightest areas are transformed into the darkest and the darkest areas are transformed into the brightest.
This conversion or transformation is used widly in the field of image processing.
Tools and Languages:
Installation
Use the package manager pip to install cv2 and numpy.
pip install cv2
pip install numpy
Import
Use import keyword to import modules.
import cv2
import numpy as np
Reading image from file
img = cv2.imread("cat.png")
Negative conversion
Image negative is produced by subtracting each pixel from the maximum intensity value.
This is a very easy method rather than manipulating individual color channels.
inv = 255-img
Completion message
print('Negative Image created.')
Comparing original vs grayscale
cv2.imshow('ORIGINAL',img)
cv2.imshow('INVERSE',inv)
cv2.waitKey(0)
cv2.destroyAllWindows()