Created
March 15, 2019 06:04
-
-
Save ChongyeWang/4337e0c134ea36eb2fb2e1d390d68d6d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
image = cv2.imread('images/input.jpg') | |
# Create a matrix of ones, then multiply it by a scaler of 100 | |
# This gives a matrix with same dimesions of our image with all values being 100 | |
M = np.ones(image.shape, dtype = "uint8") * 175 | |
# We use this to add this matrix M, to our image | |
# Notice the increase in brightness | |
added = cv2.add(image, M) | |
cv2.imshow("Added", added) | |
# Likewise we can also subtract | |
# Notice the decrease in brightness | |
subtracted = cv2.subtract(image, M) | |
cv2.imshow("Subtracted", subtracted) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment