I've been trying to modify the pixels of an image slightly, but the colors are getting distorted. So, I multiplied every pixel with 1 and saw the result.
Here's my code
import numpy as np
from matplotlib import pyplot as plt
import cv2
mud1 = cv2.imread('mud.jpeg')
print mud1.shape
mask = np.random.random_integers(1,1,size=(81,81,3))
print mask.shape
print mask[21][21][2]
print mud1[21][21][2]
mud1new = np.multiply(mud1,mask)
print mud1new[21][21][2]
plt.subplot(121),plt.imshow(mud1),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(mud1new),plt.title('Masked')
plt.xticks([]), plt.yticks([])
plt.savefig('problem.jpeg')
plt.show()
The pixels remain unchanged but somehow the image I see is different.