title: How to overlay segmented image on top of main image in python
body: <p>I have an image in RGB and another segmented image in which the pixels have 3 values(segmented image). I want to overlay the segmented image on top of the main image as the segmented areas make contours over the main image such as image below. Here the value of the segmented image pixels are 0, 1 and 2. The red contour shows the contour of pixels with value1 , the yellow contour shows the contour of pixels with 2 value and the background pixel value is 0. </p>
  
  <p><a href="https://i.stack.imgur.com/oTikG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oTikG.png" alt="enter image description here"></a></p>
  
  <p>the image is from the paper "Dilated-Inception Net: Multi-Scale FeatureAggregation for Cardiac Right VentricleSegmentation"</p>
  
  <p>Here is an example of a segmented image. </p>
  
  <p><a href="https://i.stack.imgur.com/qsOfb.jpg" rel="noreferrer">segmented image</a></p>
  
  <p>The background image can be any image. I only need these rectangle counters appear on the background image as two contours similar to red and yellow lines above. So, the output will be similar to the image below. </p>
  
  <p><a href="https://i.stack.imgur.com/8qR5M.jpg" rel="noreferrer">output image</a></p>
  
  <p>sorry as I draw rectangles by hand they are not exact. I just would like to give you an insight about the output. </p>