I am working on changing the lightness of a grayscale image. However, I have problem using numpy array when I tried to add 100 to the each pixel value and set it to 255 when the value goes over 255
import numpy as np
import matplotlib.pyplot as plt
from scipy import misc
for i in range(0, img.shape[0]):
for j in range(0, img.shape[1]):
im2[i,j] = img[i,j] + 100
if im2[i,j] > 255:
im2[i,j] = 255
plt.imshow(im2, cmap = 'gray')
plt.show()
these are the codes and I got an error message saying
if im2[i,j] > 255:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Can anyone help me out with it?
im2[i, j]a list?if im2[i, j] > 255:? What's the purpose of this line ?