title: How to generate random values that are distant from a list of values?
body: <p>I have the following transparent images.</p>
  <p><a href="https://i.stack.imgur.com/iGn3H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iGn3H.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/U0Z3j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U0Z3j.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/EnXNG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EnXNG.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/u4mhn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u4mhn.png" alt="enter image description here" /></a></p>
  <p>What I want to do is to paste them on an image with a background of a specific color. The color of the background is randomized like this:</p>
  <pre><code>rand1, rand2, rand3 = (random.randint(0, 255),
                         random.randint(0, 255),
                         random.randint(0, 255))
  
  background = Image.new('RGBA', png.size, (rand1, rand2, rand3))
  
  alpha_composite = Image.alpha_composite(background, png)
  </code></pre>
  <p>Unfortunately, some of the logos don't go well with their background colors. The background color sometimes comes close to color(s) inside the logo, which makes the logo either partially or completely invisible. Here is an example where the background color is almost identical to the orange color in the Ubuntu logo:</p>
  <p><a href="https://i.stack.imgur.com/XdH93.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XdH93.png" alt="enter image description here" /></a></p>
  <p>What I did was to get all of the colors from each logo and save them in a list of tuples like this. This is actually a list of lists of tuples. I've just edited it now to highlight which nested list of tuples belong to which logo:</p>
  <pre><code>Intel = [(0, 113, 197)]
  Corsair = [(4, 7, 7)]
  Google = [(66, 133, 244), (234, 67, 53), (251, 188, 5), (52, 168, 83), (0, 255, 255), (255, 128, 0), (255, 255, 0)]
  Riot = [(209, 54, 57), (255, 255, 255), (226, 130, 132), (0, 0, 0)]
  </code></pre>
  <p>What I want to do is to use the above ^ information to randomly choose background colours so that no part of a logo is made invisible. I'm asking for suggestions on strategies to go about this..</p>
  <p>This is the function that adds a background color to the logos:</p>
  <pre><code>def logo_background(path):
  
      rand1, rand2, rand3 = (random.randint(0, 255),
                             random.randint(0, 255),
                             random.randint(0, 255))
  
      png = Image.open(path).convert('RGBA')
      colors = extcolors.extract_from_path(path)
  
      background = Image.new('RGBA', png.size, (rand1, rand2, rand3))
  
      alpha_composite = Image.alpha_composite(background, png)
  
  
      return alpha_composite
  </code></pre>
  <pre><code>&gt;&gt;&gt; extcolors.extract_from_path(path)
  [((0, 113, 197), 25727), 56235]
  
  # for the intel logo, which is just blue with transparent background
  </code></pre>
  <p>Some logos are completely black. The corsair logo is an all black logo with transparent background but the code did not select the right background.</p>
  <p><a href="https://i.stack.imgur.com/HRiHA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HRiHA.jpg" alt="enter image description here" /></a></p>