New in Wolfram Mathematica 7: Built-in Image Processing & Analysis  previous | next 
Apply Basic Morphological Operations
The boundaries of an image can be detected automatically.
In[1]:=

Click for copyable input
{img = Image[

   BitXor[DiamondMatrix[200, 501], BoxMatrix[80, 501], 

    DiskMatrix[20, 501]]], MorphologicalPerimeter[img]}
Out[1]=