Padding
Centered padding and cropping operations for tensors.
torchlinops.functional.center_pad
Center pads the input tensor to the specified size.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The input tensor to be padded.
TYPE:
|
im_size
|
The original size of the input tensor.
TYPE:
|
pad_im_size
|
The desired size after padding.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The padded tensor. |
Notes
This function uses the Pad operator to perform the padding operation.
It calculates the necessary padding dimensions and applies the padding
to ensure that the output tensor matches the pad_im_size while preserving
the center of the original tensor.
Source code in src/torchlinops/functional/_pad.py
torchlinops.functional.center_crop
Center crops the input tensor to the specified size.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
The input tensor to be cropped.
TYPE:
|
im_size
|
The original size of the input tensor.
TYPE:
|
crop_im_size
|
The desired size after cropping.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
The cropped tensor. |
Notes
This function uses the Pad operator to perform the cropping operation.
It calculates the necessary cropping dimensions and applies the cropping
from the center of the original tensor to achieve the specified crop_im_size.