title: Image Segmentation for Color Analysis in OpenCV
body: <p>I am working on a project that requires me to:</p>
  
  <p>Look at images that contain relatively well-defined objects, e.g.</p>
  
  <p><img src="https://i.stack.imgur.com/TbaOS.jpg" alt="enter image description here"></p>
  
  <p>and pick out the color of n-most (it's generic, could be 1,2,3, etc...) prominent objects in some space (whether it be RGB, HSV, whatever) and return it. </p>
  
  <p>I am looking into ways to segment images like this into the independent objects. Once that's done, I'm under the impression that it won't be particularly difficult to find the contours of the segments and analyze them for average or centroid color, etc...</p>
  
  <p>I looked briefly into the Watershed algorithm, which seems like it could work, but I was unsure of how to generate the marker image for an indeterminate number of blobs. </p>
  
  <p>What's the best way to segment such an image, and if it's using Watershed, what's the best way to generate the corresponding marker image of integers?</p>