Mark with color on grayscale image in Matplotlib

Viewed 290

I have a grayscale image (so an 2d numpy array with values between 0 and 1) which I usually show as follows:

plt.imshow(image, cmap='gray')
plt.title(title)
plt.axis("off")
plt.show()
plt.close()

Now I want to kind of "paint" over this image with one single color (to highlight some part). Is there a way to do this in Python (preferably matplotlib)?

For example I have the Shepp Logan Phantom (https://en.wikipedia.org/wiki/Shepp–Logan_phantom), of which I want to mark the right black ellipse with a red edge. I do have an image containing only this edge (of the same size as the Phantom), so how can I "put" it with a color over the original gray scale image?

EDIT: I am actually using more complicated images with arbitrary shapes and not precise ellipses/circles, but suppose I want to highlight the following white parts of the image below (for which I cannot use perfect shapes) of the Shepp Logan phantom with red together with the rest of the Shepp Logan phantom as in the link:

enter image description here

Then my question is: how can I combine these two images (of which one should be colorized and the other one should be a grayscale image).

Thanks in advance!

0 Answers
Related