peal.data.transformations.SetChannels

class peal.data.transformations.SetChannels[source]

Bases: object

Convert a tensor image to a fixed number of channels.

Multi-channel inputs are averaged to one channel when channels == 1; single-channel inputs are tiled when channels > 1; anything else is returned unchanged (no other conversions are attempted).

Parameters:

channels (int) – Desired number of channels.

Methods

__init__(channels)[source]

Store the desired channel count.

__call__(sample)[source]

Adjust the channel count of sample.

Parameters:

sample (torch.Tensor) – Image of shape [C, H, W].

Returns:

Image of shape [channels, H, W] when a conversion applied, otherwise sample itself.

Return type:

torch.Tensor