title: how to separate image using color channel in python?
body: <p>Hello I want to separate an object based it's color into a new image using python PIL</p>
  
  <p>but I don't quite get the gasp of it. I'm still new with python.</p>
  
  <p>what I already done is a code from matlab and it works</p>
  
  <pre><code>G = imread('x.png');
  L = G;
  for i=1:217 #this is image height
      for j=1:286 #this is image width
          for k=1:3 #this is color RGB channel
              if(L(i,j,2) &lt; 174) #if green value is under 174
                  L(i,j,k) = L(i,j,k);
              else
                  L(i,j,k) = 256; #change to white
              end
  
              if(L(i,j,3) &lt; 174) #if blue value is under 174
                  L(i,j,k) = L(i,j,k);
              else
                  L(i,j,k) = 256; #change to white
              end
          end
      end
  end
  imshow(L)
  </code></pre>
  
  <p>Can I get a proper explanation about how you do it using python PIL ?</p>
  
  <p>thank you very much</p>
  
  <p><strong>edit :</strong></p>
  
  <p>What I'm trying to do is something like this</p>
  
  <p><a href="https://imgur.com/6n1QCfR" rel="nofollow noreferrer">https://imgur.com/6n1QCfR</a></p>
  
  <p>Then the result is this </p>
  
  <p><a href="https://imgur.com/p99kN5p" rel="nofollow noreferrer">https://imgur.com/p99kN5p</a></p>