Home > OS >  How to superimpose segmentation result over other image
How to superimpose segmentation result over other image

Time:09-23

I have the original image and its segmented mask. My task is to get a colored segmentation plot over the original image. I tried following enter image description here

The segmented image:

enter image description here

This is a similar example of the result I want to achieve:

An example

CodePudding user response:

It can be easily done using matplotlib.pyplot

import matplotlib.pyplot as plt

image = plt.imread('image.png')
mask = plt.imread('mask.png')

fig, ax = plt.subplots()
ax.imshow(image, cmap='gray')
ax.imshow(mask, cmap='gray', alpha=0.5)
fig.show()
fig.savefig('overlapped.png')

You can also change colors by changing colormap parameter, cmap.

  • Related