Transforms Utils¶
- class master_thesis.utils.TransformsUtils¶
Bases:
object
- static resize(image, size, mode='bilinear', keep_ratio=True)¶
Resize an image using the the algorithm given in
mode
.- Parameters
image (torch.FloatTensor) – tensor of size (C,F,H,W) containing the image quantized from [0, 1].
size (tuple) – tuple containing the desired size in the form (H, W).
mode (str) – mode used to resize the image. Same format as in
torch.nn.functional.interpolate()
.
- Returns
resized image.
- Return type
torch.FloatTensor
- static resize_set(x, v, y, size)¶
Resizes the entire set of data (x, m, y).
- Parameters
x (torch.FloatTensor) – tensor of size (B,C,F,H,W) containing masked
[0 (from) –
1] –
v (torch.FloatTensor) – tensor of size (B,1,F,H,W) containing visibility
[0 –
1] –
y (torch.FloatTensor) – tensor of size (B,C,F,H,W) containing images
[0 –
1] –
size (int) – new size of the set of data.
- static crop(image, size, crop_center=True, crop_position=None)¶
Crop a patch from the image.
- Parameters
image (torch.FloatTensor) – tensor of size (C, F, H, W) containing
image. (the) –
size (tuple) – tuple containing the desired size in the form (H, W).
crop_position (tuple) – coordinates of the top-left pixel from where
set (to cut the patch. If not) –
randomly. (it is generated) –
- Returns
patch of the image.
- Return type
torch.FloatTensor
- static dilatate(images, filter_size, iterations)¶
Dilatates an image with a filter of size
filter_size
.- Parameters
images (torch.FloatTensor) – tensor of size (1,F,H,W) containing
image. (the) –
filter_size (tuple) – size of the filter in the form (H,W).
iterations (integer) – number of times to apply the filter.
- Returns
dilatated image.
- Return type
torch.FloatTensor
- static interpolate_data(x_target, m_target, x_ref, m_ref, h_new, w_new)¶