title: How to extract a polygon from an image using imagemagick or magick++
body: <p>I would like to us Magick++ or the imagemagick command line to extract
  an n-gon from an image.  The n-gon is specified by a list the
  vertices.  So, for example I would like to be able to extract an n-gon
  defined by the points a,b,c,d,e,f,g,h which define a region that looks
  like:</p>
  
  <pre><code>      a---------h
        |         |
        |         g-f
        |           |
        b---c       |
            |       |
            |       |
            |       |
            d-------e
  </code></pre>
  
  <p>out of, for example, a png image.  I assume I have to do some kind of
  composite operation with an image mask, or if using Magick++ define a
  DrawableClipPath.  But, I can't find any documentation for this.  Any
  help would be appreciated.</p>
  
  <p>p.s. My preference is to do this using C++ and Magick++ because I have other
  processing to do, but am happy to do it with the commandline too.</p>