In [1]:
import cv2
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
# read the image

'''
# Numpy is a optimized for fast array calculations. So simply accessing each and every pixel
# values and modifying it will be very slow and it is discouraged. For individual pixel access,
# Numpy array methods, *array.item()* and *array.itemset()* is considered to be better.
# This functions always returns a scalar. So you need to call *array.item()* separately for each color.

for k in range(0,50):
for i in range(original.shape[0]):
for j in range(original.shape[1]):
original.itemset((i,j,2),original.item(i,j,2) * 0)
original.itemset((i,j,1),original.item(i,j,1) * 1.02)
original.itemset((i,j,0),original.item(i,j,0) / 1.03)
'''

# This will work, but it is pretty slow, so we will do this in a more pythonic way

for k in range(0,50):
original[:,:,0] = original[:,:,0] / 1.03
original[:,:,1] = original[:,:,1] * 1.02
original[:,:,2] = original[:,:,2] * 0

# show the results
cv2.imshow('Updated',original)
cv2.waitKey(40)
cv2.destroyAllWindows()