Class Brightness<T>
- Namespace
- AiDotNet.Augmentation.Image
- Assembly
- AiDotNet.dll
Adjusts the brightness of an image by adding a random offset to all pixel values.
public class Brightness<T> : AugmentationBase<T, ImageTensor<T>>, IAugmentation<T, ImageTensor<T>>
Type Parameters
TThe numeric type for calculations.
- Inheritance
-
AugmentationBase<T, ImageTensor<T>>Brightness<T>
- Implements
-
IAugmentation<T, ImageTensor<T>>
- Inherited Members
Remarks
Brightness adjustment simulates different lighting conditions by uniformly increasing or decreasing all pixel values. This helps models become robust to variations in ambient lighting and exposure settings.
For Beginners: Think of this like adjusting the brightness slider on your phone. Making an image brighter adds light to all pixels, making it darker subtracts light. This teaches your model to recognize objects whether they're in bright sunlight or shade.
When to use:
- Outdoor photography where lighting varies by time of day
- Indoor scenes with different lighting conditions
- Any task where exposure/lighting might vary between training and deployment
When NOT to use:
- Tasks where absolute brightness is meaningful (e.g., astronomy)
- Images already normalized to a specific brightness range
- Medical imaging where pixel intensity has diagnostic meaning
Constructors
Brightness(double, double, double)
Creates a new brightness augmentation.
public Brightness(double minFactor = 0.8, double maxFactor = 1.2, double probability = 0.5)
Parameters
minFactordoubleThe minimum brightness factor. Values below 1.0 darken the image. Industry standard default is 0.8 (20% darker at minimum).
maxFactordoubleThe maximum brightness factor. Values above 1.0 brighten the image. Industry standard default is 1.2 (20% brighter at maximum).
probabilitydoubleThe probability of applying this augmentation (0.0 to 1.0). Industry standard default is 0.5.
Remarks
For Beginners: The factor range of 0.8 to 1.2 creates subtle brightness variations that look natural. A range like 0.5 to 1.5 would create more dramatic changes. Factor of 0.0 would make the image completely black, factor of 2.0 would make it very bright.
Properties
MaxFactor
Gets the maximum brightness adjustment factor.
public double MaxFactor { get; }
Property Value
Remarks
Values greater than 1.0 brighten the image.
MinFactor
Gets the minimum brightness adjustment factor.
public double MinFactor { get; }
Property Value
Remarks
A factor of 1.0 means no change. Values less than 1.0 darken the image.
Methods
ApplyAugmentation(ImageTensor<T>, AugmentationContext<T>)
Applies the brightness adjustment to the image.
protected override ImageTensor<T> ApplyAugmentation(ImageTensor<T> data, AugmentationContext<T> context)
Parameters
dataImageTensor<T>contextAugmentationContext<T>
Returns
- ImageTensor<T>
GetParameters()
Gets the parameters of this augmentation.
public override IDictionary<string, object> GetParameters()
Returns
- IDictionary<string, object>
A dictionary of parameter names to values.