For more ways see...
IM Examples, Transforms, Edge Outlines
http://www.imagemagick.org/Usage/transform/#edge_jitter
This looks at both anti-aliased shapes, and aliased bitmap shapes, as well as a vector approach.
NOTE drawing an edge is tricky as an edge has a 0 width, BUT lines have a a width of typically 1 pixel. This means a drawn edge may be inside, outside, to top-left of or bottom right of the actual edge. Idealy you would want the middle of an anti-aliased line to match the exact edge.
NOTE: drawn shapes does not draw edges exactly where specified, but at a point 1/2 pixel wider than it should be.
This means two shapes drawn using the same edge overlap by 1 pixel.
See Draw Fill Bounds
http://www.imagemagick.org/Usage/draw/#bounds