diff --git a/Image_Processing/src/negative/Pipfile b/Image_Processing/src/negative/Pipfile new file mode 100644 index 00000000..0905a4c4 --- /dev/null +++ b/Image_Processing/src/negative/Pipfile @@ -0,0 +1,15 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pillow = "*" +numpy = "*" +matplotlib = "*" +opencv-python = "*" + +[dev-packages] + +[requires] +python_version = "3.7" diff --git a/Image_Processing/src/negative/Pipfile.lock b/Image_Processing/src/negative/Pipfile.lock new file mode 100644 index 00000000..9a51a282 --- /dev/null +++ b/Image_Processing/src/negative/Pipfile.lock @@ -0,0 +1,20 @@ +{ + "_meta": { + "hash": { + "sha256": "7e7ef69da7248742e869378f8421880cf8f0017f96d94d086813baa518a65489" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.7" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": {} +} diff --git a/Image_Processing/src/negative/img/PeppersRGB.jpg b/Image_Processing/src/negative/img/PeppersRGB.jpg new file mode 100644 index 00000000..8a902089 Binary files /dev/null and b/Image_Processing/src/negative/img/PeppersRGB.jpg differ diff --git a/Image_Processing/src/negative/negative.py b/Image_Processing/src/negative/negative.py new file mode 100644 index 00000000..338639a0 --- /dev/null +++ b/Image_Processing/src/negative/negative.py @@ -0,0 +1,51 @@ +import math + +from copy import deepcopy +import cv2 +import matplotlib.pyplot as plt +import numpy as np +from PIL import Image + + +def negative(r,g,b): + r = int(255-r) + g = int(255-g) + b = int(255-b) + return [r, g, b] + + +def setRGB(r,g,b): + r = int(r) + g = int(g) + b = int(b) + return [r, g, b] + +img = Image.open('img/PeppersRGB.jpg') +img = np.asarray(img) + +colorImg = deepcopy(img) + +for i in range(len(img)): + for j in range(len(img[i])): + pixelR = int (img[i][j][0]) + pixelG = int (img[i][j][1]) + pixelB = int (img[i][j][2]) + + colorImg[i][j] = negative(pixelR,pixelG,pixelB) + + + + + + +plt.subplot(2,2,1) +plt.imshow(img) +plt.subplot(2,2,2) +plt.hist(img.ravel(),256,[0,256]) +plt.subplot(2,2,3) +plt.imshow(colorImg) +plt.subplot(2,2,4) +plt.hist(colorImg.ravel(),256,[0,256]) + + +plt.show()