title: Adjusting the contrast of an image
body: <p>I am trying to do image contrast without using any python libraries. Personally i feel it's better to learn how to code without using the various libraries to get a better understanding. In my case i am trying to avoid using opencv to contrast an image. </p>
  
  <p>The issue i'm having is <code>TypeError: 'int' object has no attribute '__getitem__'</code>. Honestly, I'm not quite sure what this error means. </p>
  
  <pre><code>import matplotlib.pylab as plt
  import matplotlib.image as mpimg
  import numpy as np
  
  img = np.uint8(mpimg.imread('igloo.png'))
  
  img = np.uint8((0.2126* img[:,:,0]) + \
      np.uint8(0.7152 * img[:,:,1]) +\
           np.uint8(0.0722 * img[:,:,2]))
  
  def img_contrast(img):
     for x in range(img.size[0]):
         for y in range(img.size[1]):
             if (x, y) &gt; 128:
                (r, g, b) = img.getpixel((x, y))
                img.putpixel((x, y), (r+80, g+80, b+80))
             else:
                if(x, y) &lt; 128:
                   (r, g, b) = img.getpixel((x, y))
                   img.putpixel((x, y), (r-80, g-80, b-80))
  
  tam = img_contrast(img)
  
  plt.imshow(tam)
  </code></pre>