plenoptic.data.disk#

plenoptic.data.disk(img_size, outer_radius=None, inner_radius=None)[source]#

Create a circular mask with softened edges.

All values within inner_radius will be 1, and all values from inner_radius to outer_radius will decay smoothly to 0.

Parameters:
  • img_size (int | tuple[int, int] | Size) – Size of image in pixels.

  • outer_radius (float | None (default: None)) – Total radius of disk. Values from inner_radius to outer_radius will decay smoothly to zero.

  • inner_radius (float | None (default: None)) – Radius of inner disk. All elements from the origin to inner_radius will be set to 1.

Return type:

Tensor

Returns:

mask – Tensor mask with torch.Size(img_size).

Examples

>>> import plenoptic as po
>>> import torch
>>> disk = po.data.disk((256, 256), outer_radius=50, inner_radius=25)
>>> # we can add batch and color dimensions
>>> # (this is equivalent to using .unsqueeze(0) twice)
>>> disk = disk[None, None]
>>> # we can use the disk as a mask to apply to an image
>>> img = po.data.einstein()
>>> masked_img = img * disk
>>> po.plot.imshow(
...     [disk, img, masked_img], title=["disk", "image", "mask applied"]
... )
<PyrFigure ...>

(png, hires.png, pdf)

../../_images/plenoptic-data-disk-1.png