prtools.pixelate#
- pixelate(img, oversample=1)[source]#
Apply the aperture effects of an idealized square pixel using the FFT.
- Parameters:
img (array_like) – Input image
oversample (float, optional) – Oversampling factor of img. Default is 1.
- Returns:
out – Image with pixel sampling effects applied.
- Return type:
ndarray
Notes
To avoid the introduction of numerical artifacts, this function should be performed on data that is at least 2x oversampled.
Examples
>>> img = prtools.circle((17,17), 5) >>> img_pixelate = prtools.pixelate(img) >>> fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(5,2)) >>> ax[0].imshow(img, cmap='gray') >>> ax[0].set_title('Input image') >>> ax[1].imshow(img_pixelate, cmap='gray') >>> ax[1].set_title('Pixelated image')
Note that the pixelation process preserves image power:
>>> print(np.sum(img), np.sum(img_pixelate)) 64.0, 64.0