Skip to content

Adding 'crop' option(s) to RandomRotation #9147

Open
@diaz-esparza

Description

@diaz-esparza

🚀 The feature

Adding an option to the RandomRotation Transform to crop its output to an area that does not contain any 'padding' (black corners).

Motivation, pitch

I was working on surface-defect-classification models (and generally models that classify 'flat pane' objects), and it once I implemented it, it proved as a useful augmentation for this kind of paradigm!

Alternatives

The Albumentations library has this option for the analogous Rotate function, but I think having the feature here wouldn't be very difficult either.

Additional context

The most popular implementation for this type of transform just finds an inscribed rectangle with the largest possible area. Albumentations did that, and put the setting as a bool (and honestly, I think that option would more than adequate for us too).

For some niche use cases it might also be useful to add the constraint that the aspect ratio must remain constant. That is something that I used, so the setting could also be a LiteralString...? As you prefer, really!

If you'll allow me, there's even another thing which would actually be very useful for me, which is that we could take advantage of the fact that there are theoretically infinite optimal solutions for non-squares! (Think of it as the inscribed rectangle being able to 'slide around' the rotated one). This could prove useful if used as another random element in the augmentation transform, although I'm unsure right now on how that interface could be implemented 😅

Anyways, I have the implementations for all of these options lying around already, so please let me know if you would like me adding any of these new features to the library :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy