Skip to content

RandFlip operates on all axes or none #2245

@rijobro

Description

@rijobro

Is your feature request related to a problem? Please describe.
For data augmentation, you might want to flip your images. You might want to flip it around any of the dimensions, either all at the same time or with some combination. The current code, however, only allows for flipping across all or none of the dimensions.

The current solution is therefore to chain multiple transforms together, but I feel a single transform should be able to give this functionality.

Current workaround:

RandFlipd(["image", "label"], prob=0.5, spatial_axis=0),
RandFlipd(["image", "label"], prob=0.5, spatial_axis=1),

Describe the solution you'd like

def randomize(data):
    if isinstance(self.spatial_axis, int):
        self.sampled_spatial_axis = self.spatial_axis
    else:
        sample = np.random.randint(2, size=len(self.sampled_spatial_axis))
        self.sampled_spatial_axis = np.array(self.sampled_spatial_axis)[sample].tolist()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions