title: How to Access and Change Color Channels using PIL?
body: <p>I'm trying to access the RGB color channels of an image using <code>PIL</code>, and then change the color intensity of the color channel of the entire image at once.  </p>
  
  <p>When I say RGB color channels, <a href="https://www.researchgate.net/figure/Transformation-RGB-colour-model-in-3-dimensional-colour-layer-into-2-dimensional-matrix_fig1_233885817" rel="noreferrer">here</a> is an online example.</p>
  
  <p>I don't understand if this has to be done on a pixel by pixel basis or not. </p>
  
  <p>I image the logic of the code would look like this:</p>
  
  <pre><code>import PIL
  from PIL import Image
  image=Image.open("my_pic.gif")
  image=image.convert('RGB')
  # made up function
  channel_values = image.get_channel_values()
  #channel_values = i.e. (50, 100, 50)
  # do some math function to transform channel_values
  channel_values = (95,125,75)
  image.update_channel_value('R',channel_values)
  display(image.getchannel('R'))
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/51543824/3225420">This</a> answer is the only one that comes close, but it is way too complicated for what I'm trying to do.</p>
  
  <p>I've searched the PIL docs, etc. for a couple of hours but can't seem to get anywhere.</p>
  
  <p>Here's how far I've gotten:</p>
  
  <pre><code>import PIL
  from PIL import Image
  image=Image.open("my_pic.gif")
  image=image.convert('RGB')
  display(image.getchannel('R'))
  </code></pre>
  
  <p>The problem is the <code>image.getchannel()</code> only returns a grey/black &amp; white image.  </p>
  
  <p>I not only want to access the color channel value, I want to change it too.</p>