title: remove a particular color from an image
body: <p>Is it possible to remove a particular rbg color from an image? For example, I want to create a function such that I pass an image and color as a parameter and it returns the same image but without that color.</p>
  <p>For example, this function</p>
  <p><strong>fuction(image, &quot;R&quot;)</strong></p>
  <p>should give me an image that has no R shades. How can I do so?</p>
  <p>Currently, something like this works:</p>
  <pre><code>def exclusionWithPIL(image, channel):
      out = None
      image = Image.open(image)
      image_data = image.load()
      height,width = image.size
      for loop1 in range(height):
          for loop2 in range(width):
              r,g,b = image_data[loop1,loop2]
              image_data[loop1,loop2] = 0,g,b
      return image
  
  result = rgb_exclusion('./image.jpg', &quot;G&quot;)
  result.save('new.jpg')
  </code></pre>
  <p>but here, I'm reading the image like this <code>Image.open(image)</code> inside the function. Instead, I want to pass in <code>image1</code> which is already read like this:</p>
  <pre><code>image1 = load(image1_path)
  </code></pre>
  <pre><code>def load(image_path):
      out = io.imread(image_path)
      out = out.astype(np.float64) / 255
      return out
  </code></pre>
  <p>How can I modify the function accordingly?
  P.S I use io.imread from skimage to read images.</p>
  <p>Edit:
  if I pass the image loaded by io.imread directly into the function, something like this seems to work:</p>
  <pre><code>    out = image.copy()
      if (channel == &quot;R&quot;):
          out[:, :, 0] = 0
  </code></pre>
  <p>But I don't quite quite understand the indexes <code>[:, :, 0]</code></p>