ImageDev

GetColorChannel

Extracts a given channel from a color image into a grayscale image.

Access to parameter description

For an introduction to image filters: section Color Transforms.

GetColorChannel extracts a given channel from any color image (RGB, HSL, multi-channel, ...) into the output grayscale image.

See also

Function Syntax

This function returns outputGrayImage.
// Function prototype
std::shared_ptr< iolink::ImageView > getColorChannel( std::shared_ptr< iolink::ImageView > inputColorImage, int32_t channel, std::shared_ptr< iolink::ImageView > outputGrayImage = nullptr );
This function returns outputGrayImage.
// Function prototype.
get_color_channel(input_color_image: idt.ImageType,
                  channel: int = 1,
                  output_gray_image: idt.ImageType = None) -> idt.ImageType
This function returns outputGrayImage.
// Function prototype.
public static IOLink.ImageView
GetColorChannel( IOLink.ImageView inputColorImage,
                 Int32 channel = 1,
                 IOLink.ImageView outputGrayImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputColorImage
The color or multi-channel input image. Image Multispectral nullptr
input
channel
The index of the channel to extract. In the case of an RGB input: 0 for Red, 1 for Green, 2 for Blue. Int32 >=0 1
output
outputGrayImage
The grayscale output image representing the extracted channel. Its spatial dimensions and type are forced to the same values as the input. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_color_image
The color or multi-channel input image. image Multispectral None
input
channel
The index of the channel to extract. In the case of an RGB input: 0 for Red, 1 for Green, 2 for Blue. int32 >=0 1
output
output_gray_image
The grayscale output image representing the extracted channel. Its spatial dimensions and type are forced to the same values as the input. image None
Parameter Name Description Type Supported Values Default Value
input
inputColorImage
The color or multi-channel input image. Image Multispectral null
input
channel
The index of the channel to extract. In the case of an RGB input: 0 for Red, 1 for Green, 2 for Blue. Int32 >=0 1
output
outputGrayImage
The grayscale output image representing the extracted channel. Its spatial dimensions and type are forced to the same values as the input. Image null

Object Examples

auto ateneub = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "ateneub.jpg" );

GetColorChannel getColorChannelAlgo;
getColorChannelAlgo.setInputColorImage( ateneub );
getColorChannelAlgo.setChannel( 1 );
getColorChannelAlgo.execute();

std::cout << "outputGrayImage:" << getColorChannelAlgo.outputGrayImage()->toString();
ateneub = ioformat.read_image(imagedev_data.get_image_path("ateneub.jpg"))

get_color_channel_algo = imagedev.GetColorChannel()
get_color_channel_algo.input_color_image = ateneub
get_color_channel_algo.channel = 1
get_color_channel_algo.execute()

print("output_gray_image:", str(get_color_channel_algo.output_gray_image))
ImageView ateneub = ViewIO.ReadImage( @"Data/images/ateneub.jpg" );

GetColorChannel getColorChannelAlgo = new GetColorChannel
{
    inputColorImage = ateneub,
    channel = 1
};
getColorChannelAlgo.Execute();

Console.WriteLine( "outputGrayImage:" + getColorChannelAlgo.outputGrayImage.ToString() );

Function Examples

auto ateneub = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "ateneub.jpg" );

auto result = getColorChannel( ateneub, 1 );

std::cout << "outputGrayImage:" << result->toString();
ateneub = ioformat.read_image(imagedev_data.get_image_path("ateneub.jpg"))

result = imagedev.get_color_channel(ateneub, 1)

print("output_gray_image:", str(result))
ImageView ateneub = ViewIO.ReadImage( @"Data/images/ateneub.jpg" );

IOLink.ImageView result = Processing.GetColorChannel( ateneub, 1 );

Console.WriteLine( "outputGrayImage:" + result.ToString() );