def __init__(self, width, sample_spacing=0.025, samples=384):
''' Produces a Pinhole.
Args:
width (`float`): the width of the pinhole.
sample_spacing (`float`): spacing of samples in the synthetic image.
samples (`int`): number of samples per dimension in the synthetic image.
'''
self.width = width
# produce coordinate arrays
ext = samples / 2 * sample_spacing
x, y = np.linspace(-ext, ext, samples), np.linspace(-ext, ext, samples)
xv, yv = np.meshgrid(x, y)
w = width / 2
# paint a circle on a black background
arr = np.zeros((samples, samples))
arr[sqrt(xv**2 + yv**2) < w] = 1
super().__init__(data=arr, sample_spacing=sample_spacing, synthetic=True)
评论列表
文章目录