title: Efficient segment boundary marking after segmentation of an image
body: <p>One can mark the boundary of a binary image by <em>bwboundaries</em> function of MATLAB.</p>
  
  <p>What should be done for obtaining boundaries of all segments as a binary image?</p>
  
  <p>I have segmented an image and want to know if there is a way to mark boundaries between each neighbouring segment without applying morphological operations on each segment.</p>
  
  <p>I have added images to illustrate what i want to do. Actually i want to obtain a binary image that keeps pink boundary marker pixels between all segments. Thus, I can overlay them with original image by the help of <a href="http://www.mathworks.com/matlabcentral/fileexchange/10502-image-overlay" rel="nofollow noreferrer">imoverlay</a> function of Steve Eddins.</p>
  
  <p>Random colored labeling of segmentation result:</p>
  
  <p><img src="https://i.stack.imgur.com/qPiA3.png" alt="enter image description here"></p>
  
  <p>Roughly-marked pink boundaries between segments:</p>
  
  <p><img src="https://i.stack.imgur.com/iJ2DL.png" alt="enter image description here"></p>