How to plot a full resolution RGB picture from 3D array?

Viewed 89

I used the imshow method from matplotlib.pyplot to plot a gray scale picture, and I removed the x and y axis, as well as the blank left by the removed x and y axis. The size of the 3D array is 2048*2048*3 and I thought by setting the figsize=(4,4) and dpi = 512, I will get a picture of 2048*2048 pixels. However, the output picture was 1546*1546.

Why do I come across these problems? And how can I fix it?

Here is my code for the plot part.

plt.figure(figsize=(4,4))
plt.imshow(data) 
plt.axis('off') 
plt.yticks([]) 
plt.xticks([]) 
plt.savefig('..\\img\\'+file+'.jpg', bbox_inches='tight', dpi=512, pad_inches=0.0) 
plt.close()
0 Answers
Related