'Python - Mask Boundary not accurate with transparent backgound

I have a binary mask. I tried to extract the boundary of the mask by using - These are the contours extracted

contours = skimage.segmentation.find_boundaries(mask)
contours = np.where(contours==0, np.nan, image)

And then I try to remove the background (as shown)so that I can embed the mask on the original image (which is a medical image). But on doing so, the plot shows nothing.

figure = plt.figure()
plt.imshow(contours, cmap = "plasma")
plt.axis('off')
plt.savefig("xyz.png")
plt.close()

Can anyone help me out please. The same thing works if I do it on the original mask without taking out the boundaries and it works when I embed it on the image as well, but I can't display the image as it is a private dataset..

Whole mask with no background



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source