I know some some people have asked this problem before, but the solutions they provided seems do not work to mine. I just give the links below and maybe they are helpful for you.
Matplotlib plots: removing axis, legends and white spaces
How to set the margins for a matplotlib figure?
As described in the problem title, I use following code to handle this problem.
plt.imshow(img)
plt.axis('off')
plt.savefig('seg_missi5.png', bbox_inches='tight')
plt.show()
And I want the saved image with no white spaces and the same size with the original one.
I have tried using print img.shape to see the size of img, it shows (342, 548, 3), which is the same as the original one, but the saved image, it don't. It's size if 438 x 675, which is bigger and has white spaces.