You have to choose a resampling method with nearest-neighbor interpolation. In pillow
use something like
w, h = bw_image.size
scale_factor = 16
img_scaled = bw_image.resize((w * scale_factor, h * scale_factor), resample=Image.NEAREST)
where scale_factor
is your integer scaling factor. Result:
When using matplotlib
you can also only scale for display, i.e.
import matplotlib.pyplot as plt
plt.imshow(bw_data, cmap='gray', interpolation='nearest')