Function libcacaoimage::ChangeChannelLayout

Function Documentation

Image libcacaoimage::ChangeChannelLayout(const Image &src, Image::Layout layout)

Adjust the channel layout of an Image.

Conversion Rules:

  • When converting to grayscale, the equation is this: gray = 0.2126r + 0.7152g + 0.0722b (ITU recommendation BT.709)

  • When converting to RGB from grayscale, all of the RGB channels are set to the same value (the grayscale value)

  • Whenever alpha is added, it is as a fully opaque channel

Parameters:
  • src – The source image

  • layout – The new image layout

Throws:

std::runtime_error – If the source image’s layout is the same as the new layout

Returns:

A new image with the new layout