RandomResizedCrop<T>

Models & Types · AiDotNet.Augmentation.Image

Randomly crops and resizes a region of the image (PyTorch-style RandomResizedCrop).

Inheritance: AugmentationBase<T, ImageTensor<T>> → SpatialAugmentationBase<T, ImageTensor<T>> → SpatialImageAugmenterBase<T> → RandomResizedCrop<T>

For Beginners

This picks a random-sized chunk of the image (from 8% to 100% of the area) with a random shape (from slightly tall to slightly wide), then resizes it to a fixed size. This teaches your model to recognize objects at different scales and crops.

How It Works

RandomResizedCrop first extracts a random crop with an area between MinScale and MaxScale of the original, with an aspect ratio between MinRatio and MaxRatio, then resizes to the target output size. This is the standard training augmentation for ImageNet and many other tasks.

When to use:

  • Standard ImageNet training pipeline (the single most important augmentation)
  • Any classification task as default training augmentation
  • Self-supervised learning (SimCLR, BYOL, etc.)

Constructors

Constructor Summary
RandomResizedCrop(int outputHeight, int outputWidth, double minScale, double maxScale, double minRatio, double maxRatio, InterpolationMode interpolation, double probability) Creates a new RandomResizedCrop.
RandomResizedCrop(int outputSize, double minScale, double maxScale, double minRatio, double maxRatio, InterpolationMode interpolation, double probability) Creates a square RandomResizedCrop.

Properties

Property Summary
InterpolationMode Interpolation { get; } Gets the interpolation mode.
double MaxRatio { get; } Gets the maximum aspect ratio (width/height).
double MaxScale { get; } Gets the maximum scale (fraction of image area).
double MinRatio { get; } Gets the minimum aspect ratio (width/height).
double MinScale { get; } Gets the minimum scale (fraction of image area).
int OutputHeight { get; } Gets the target output height.
int OutputWidth { get; } Gets the target output width.

Methods

Method Summary
IDictionary<string, object> GetParameters()