ToFloat<T>

Models & Types · AiDotNet.Augmentation.Image

Converts an image tensor to floating-point representation with configurable scaling.

Inheritance: AugmentationBase<T, ImageTensor<T>> → ImageAugmenterBase<T> → ToFloat<T>

For Beginners

Sometimes images come in different formats: 8-bit (0-255), 16-bit (0-65535), or already floating point. This transform lets you convert between any of these ranges. For example, converting 16-bit medical images to [0, 1] range.

How It Works

ToFloat provides flexible conversion of image pixel values to floating-point range. Unlike ToTensor which always divides by 255, ToFloat allows custom source and target ranges.

When to use:

  • Converting 16-bit images (e.g., medical, satellite) to [0, 1]
  • Mapping to custom ranges like [-1, 1]
  • When you need more control than ToTensor provides

Constructors

Constructor Summary
ToFloat(double sourceMin, double sourceMax, double targetMin, double targetMax, double probability) Creates a new ToFloat augmentation.

Properties

Property Summary
double SourceMax { get; } Gets the maximum value of the source range.
double SourceMin { get; } Gets the minimum value of the source range.
double TargetMax { get; } Gets the maximum value of the target range.
double TargetMin { get; } Gets the minimum value of the target range.

Methods

Method Summary
IDictionary<string, object> GetParameters()
ToFloat<T> From16Bit(double probability) Creates a ToFloat for 16-bit images to [0, 1].
ToFloat<T> ToNegativeOneToOne(double probability) Creates a ToFloat that maps [0, 255] to [-1, 1].