Padding & Truncation
torchlinops.linops.Pad
Bases: NamedLinop
Zero Pad the last dimensions of the input volume Padding is centered: - TODO: support non-centered padding? ishape: [B... Nx Ny [Nz]] oshape: [B... Nx1 Ny1 [Nz1]]
Source code in src/torchlinops/linops/pad_last.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
__init__
__init__(
pad_im_size: tuple[int, ...],
im_size: tuple[int, ...],
in_shape: Optional[Shape] = None,
out_shape: Optional[Shape] = None,
batch_shape: Optional[Shape] = None,
)
| PARAMETER | DESCRIPTION |
|---|---|
pad_im_size
|
Target (padded) size for the last dimensions. |
im_size
|
Original (unpadded) size for the last dimensions. |
in_shape
|
Named shape for the input spatial dimensions.
TYPE:
|
out_shape
|
Named shape for the output spatial dimensions.
TYPE:
|
batch_shape
|
Named shape for batch dimensions.
TYPE:
|
Source code in src/torchlinops/linops/pad_last.py
torchlinops.linops.Crop
torchlinops.linops.Truncate
Bases: NamedLinop
Truncation (slicing) operator along the last dimension.
Extracts a contiguous slice from the input. The adjoint zero-pads back to the original size.
Source code in src/torchlinops/linops/trunc_pad.py
__init__
Source code in src/torchlinops/linops/trunc_pad.py
torchlinops.linops.PadDim
Bases: NamedLinop
Zero-padding operator along a specified dimension.
Pads the input with zeros. The adjoint truncates (slices) back to the original size.