text: Q:
  
  how to find 16 most common colors in the img with extension BMP
  
  for(int yy=0; yy<height/2; yy++)
  {
    SDL_Color kolor = getPixel(xx,yy); //we are gettig each pixel in img;
  
   setPixel(xx+width/2,yy+height/2,kolor.r,kolor.g,kolor.b );
  
   //setPixel(xx,yy+height/2,kolor.r,kolor.g,kolor.b);
  
   //setPixel(xx+width/2,yy,kolor.r,kolor.g,kolor.b);
  
  }
  
  }
  I am trying by using a loop find 16 most common colors in an img and get its RGB.
  I've been using mapping and trying to do something with structure but everything was in avail. 
  If you have some ideas about how to find these colors, I'll be sorely grateful. Thanks
  
  A:
  
  If you had a 4x4 img it would be simple.
  Simplify likewise, histogram function each RGB level(0-255x3), expecting each "popular" color to be in there. Sort the mess into top 16 used for each, again expecting those to be correct. Unless you have wild color gyrations, nothing else.
  Check second time to see if popular colors actually exist.
  Last, you might want to group into "close enough" categories, jpegs are lossy to a fault, anything within 4 RGB variations is grouped together, reducing 0-256 values to 0-64, unless colors swing widely. If you've used paint program magic wand, you know tolerance=0 makes uber mistakes, same idea.
  Median filter. It will definitely reduce color count by merging into an average messy color, sample a 3x3, 4x4, circular weighted sample area.
  If all else fails, steal the 256 color safe web palette, and work from there.
  SWAG-Scientific Wild Ass Guess method, good luck.
  
  