Documentation for Basic Warping Transform¶
WarpTransform ¶
Bases: Module
A base class for applying warp transformations to images using a grid sampling approach.
This class provides the framework for implementing various warp transformations by
defining a common interface. Subclasses should implement the generate_warp_field
method to provide the specific warp grid for the transformation.
forward ¶
forward(img)
Applies the warp transformation to the input image tensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img |
Tensor
|
The input image tensor of shape (N, C, H, W). |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The warped image tensor. |
generate_warp_field ¶
generate_warp_field(height, width)
Generates the warp field for the transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height |
int
|
The height of the image. |
required |
width |
int
|
The width of the image. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The grid for warping the image. |
visualize_warp_field ¶
visualize_warp_field(height=1024, width=1024, padding=1, bg_color=1.0, grid_color=0.13)
Visualizes the warp field by creating an intermediate image with a grid and applying the warp transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height |
int
|
The height of the intermediate image (default is 1024). |
1024
|
width |
int
|
The width of the intermediate image (default is 1024). |
1024
|
padding |
int
|
The padding around the grid lines (default is 1). |
1
|
bg_color |
float
|
The background color of the intermediate image (default is 1.0, white). |
1.0
|
grid_color |
float
|
The color of the grid lines (default is 0.13, dark gray). |
0.13
|