Most prevalent color on a background by changing color space <p>I have a sheet of paper on another surface. I want to figure out when the paper ends and the surface begins. </p> <p>I'm using this approach: 1. Convert image to pixel array 2. Pick 3 random 20x20 squares and frequency count the colors 3. The highest frequency is the background</p> <p>However, the problem is that I get over 100 colors every time I do this on an actual image taken by the camera.</p> <p>I think I can fix it by putting the image in 16 colors palette. Is there a way to do this change on a UIImage or CGImage?</p> <p>Thanks</p>