I try to display images inside a Jupyter notebook. To do that, I use a code like the following one:
import numpy as np
import matplotlib.pyplot as plt
for N in [20, 100, 300]:
x, y = np.meshgrid(np.linspace(1,N,N), np.linspace(1,N,N))
img = (x+y) % 2
plt.figure()
plt.imshow(img,cmap='gray')
plt.title("Image shape: " + str(img.shape));
I obtain the images below:
As you can see, the images are not properly displayed because they are resized so as to have the same size on the screen. Therefore, the images are interpolated (to the nearest neighbors), creating unwanted aliasing. This is too bad for image processing...
I tried to define figsize
and dpi
in figure
, but that not works.