Transformations
This module defines several image transformation classes using PyTorch and NumPy.
The PolarCoordinateTransform
class converts a Cartesian image to polar
coordinates, which can be useful for certain types of image analysis.
The ShiftRowsTransform
class shifts the rows of an image so that the row with the
smallest sum is positioned at the bottom, which can help in aligning images for further processing.
The ToUnboundTensor
class converts an image to a tensor without normalizing it,
preserving the original pixel values.
Lastly, the SpiderMask
class applies a circular mask to the image, simulating
the effect of a spider by setting pixels outside the mask to a background value,
which can be useful in certain experimental setups.
PolarCoordinateTransform()
Bases: Module
Transform a Cartesian image to polar coordinates.
Source code in src/speckcn2/transformations.py
24 25 |
|
forward(img)
forward method of the transform Args: img (PIL Image or Tensor): Image to be scaled.
Returns: PIL Image or Tensor: Rescaled image.
Source code in src/speckcn2/transformations.py
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 |
|
ShiftRowsTransform()
Bases: Module
Shift the rows of an image such that the row with the smallest sum is at the bottom.
Source code in src/speckcn2/transformations.py
101 102 |
|
SpiderMask()
Bases: Module
Apply a circular mask to the image, representing the effect of the spider.
The pixels outside the spider are set to -0.01, such that their value is lower than no light in the detector (0).
Source code in src/speckcn2/transformations.py
139 140 |
|
ToUnboundTensor()
Bases: Module
Transform the image into a tensor, but do not normalize it like torchvision.ToTensor.
Source code in src/speckcn2/transformations.py
122 123 |
|