title: Python - finding the most used colour in an image - script seems to find inaccurate colours
body: <p>I wrote a script that finds the top 3 most common colours used in a jpg file. It works for the most part, but I noticed that I have some outliers.</p>
  
  <p>The image in question is this one: <a href="https://public.tableau.com/s/sites/default/files/media/votd_02_08_13_snip.png" rel="nofollow noreferrer">https://public.tableau.com/s/sites/default/files/media/votd_02_08_13_snip.png</a></p>
  
  <p>I have downloaded and saved it as jpg.</p>
  
  <p>My script detects the following colours, which are completely off:</p>
  
  <ol>
  <li>255, 176, 213</li>
  <li>197, 255, 255</li>
  <li>174, 187, 120</li>
  </ol>
  
  <p>My script:</p>
  
  <pre><code>from PIL import Image
  from collections import Counter
  
  def most_frequent_colour2(img):
      width, height = img.size
  
      r_total = []
      g_total = []
      b_total = []
  
      for x in range(0, width):
          for y in range(0, height):
  
              # Define r, g, b for the rgb colour space and fetch the RGB colour for each pixel
              r, g, b = img.getpixel((x,y))
  
              r_total.append(r)
              g_total.append(g)
              b_total.append(b)       
  
      # Count the most common colours
      r_dict, g_dict, b_dict = Counter(r_total), Counter(g_total), Counter(b_total)
  
      #pick the top 3 most frequent colours
      return r_dict.most_common(3), g_dict.most_common(3), b_dict.most_common(3)
  
  file = r"Filepath\https://public.tableau.com/s/sites/default/files/media/votd_02_08_13_snip.jpg"
  img = Image.open(file)
  img = img.convert('RGB')
  colour = most_frequent_colour2(img)
  
  # colour has the following format: 
  #([(Most frequent R value, number of occurences), (2nd most frequent R value, number of occurences)],
  # [(Most frequent G value, number of occurences), (2nd most frequent G value, number of occurences)]
  # [(Most frequent B value, number of occurences), (2nd most frequent B value, number of occurences)])
  print(colour)
  </code></pre>
  
  <p>The script works really well for this image: <a href="https://public.tableau.com/s/sites/default/files/media/tourdefrance1.jpg" rel="nofollow noreferrer">https://public.tableau.com/s/sites/default/files/media/tourdefrance1.jpg</a> where it returns 85, 85, 85 as dominant colour. </p>
  
  <p>Could the issue be the conversion from png to jpg?</p>