mmagic.datasets.transforms.alpha
¶
Augmentation on alpha matte.
Module Contents¶
Classes¶
Generate segmentation mask from alpha matte. |
|
Generate soft segmentation mask from input segmentation mask. |
- class mmagic.datasets.transforms.alpha.GenerateSeg(kernel_size=5, erode_iter_range=(10, 20), dilate_iter_range=(15, 30), num_holes_range=(0, 3), hole_sizes=[(15, 15), (25, 25), (35, 35), (45, 45)], blur_ksizes=[(21, 21), (31, 31), (41, 41)])[source]¶
Bases:
mmcv.transforms.BaseTransform
Generate segmentation mask from alpha matte.
- Parameters
kernel_size (int, optional) – Kernel size for both erosion and dilation. The kernel will have the same height and width. Defaults to 5.
erode_iter_range (tuple, optional) – Iteration of erosion. Defaults to (10, 20).
dilate_iter_range (tuple, optional) – Iteration of dilation. Defaults to (15, 30).
num_holes_range (tuple, optional) – Range of number of holes to randomly select from. Defaults to (0, 3).
hole_sizes (list, optional) – List of (h, w) to be selected as the size of the rectangle hole. Defaults to [(15, 15), (25, 25), (35, 35), (45, 45)].
blur_ksizes (list, optional) – List of (h, w) to be selected as the kernel_size of the gaussian blur. Defaults to [(21, 21), (31, 31), (41, 41)].
- static _crop_hole(img, start_point, hole_size)[source]¶
Create a all-zero rectangle hole in the image.
- Parameters
img (np.ndarray) – Source image.
start_point (tuple[int]) – The top-left point of the rectangle.
hole_size (tuple[int]) – The height and width of the rectangle hole.
- Returns
The cropped image.
- Return type
np.ndarray
- class mmagic.datasets.transforms.alpha.GenerateSoftSeg(fg_thr=0.2, border_width=25, erode_ksize=3, dilate_ksize=5, erode_iter_range=(10, 20), dilate_iter_range=(3, 7), blur_ksizes=[(21, 21), (31, 31), (41, 41)])[source]¶
Bases:
mmcv.transforms.BaseTransform
Generate soft segmentation mask from input segmentation mask.
Required key is “seg”, added key is “soft_seg”.
- Parameters
fg_thr (float, optional) – Threshold of the foreground in the normalized input segmentation mask. Defaults to 0.2.
border_width (int, optional) – Width of border to be padded to the bottom of the mask. Defaults to 25.
erode_ksize (int, optional) – Fixed kernel size of the erosion. Defaults to 5.
dilate_ksize (int, optional) – Fixed kernel size of the dilation. Defaults to 5.
erode_iter_range (tuple, optional) – Iteration of erosion. Defaults to (10, 20).
dilate_iter_range (tuple, optional) – Iteration of dilation. Defaults to (3, 7).
blur_ksizes (list, optional) – List of (h, w) to be selected as the kernel_size of the gaussian blur. Defaults to [(21, 21), (31, 31), (41, 41)].