plenoptic.process.center_crop#
- plenoptic.process.center_crop(x, output_size)[source]#
Crop out the center of a signal.
If x has an even number of elements on either of those final two dimensions, we round up.
- Parameters:
- Return type:
- Returns:
cropped – Tensor whose last two dimensions have each been cropped to
output_size.- Raises:
TypeError – If
output_sizeis not a single int.ValueError – If
output_size is not positive or larger than the height/width of ``x.
Examples
>>> import plenoptic as po >>> img = po.data.einstein() >>> img.shape torch.Size([1, 1, 256, 256]) >>> crop = po.process.center_crop(img, 128) >>> crop.shape torch.Size([1, 1, 128, 128]) >>> po.plot.imshow([img, crop], title=["input", "cropped"]) <PyrFigure ...>