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 the outputGrayImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
getColorChannel( std::shared_ptr< iolink::ImageView > inputColorImage,
                 int32_t channel,
                 std::shared_ptr< iolink::ImageView > outputGrayImage = NULL );
This function returns the outputGrayImage output parameter.
// Function prototype.
get_color_channel( input_color_image, channel = 1, output_gray_image = None )
This function returns the outputGrayImage output parameter.
// Function prototype.
public static IOLink.ImageView
GetColorChannel( IOLink.ImageView inputColorImage,
                 Int32 channel = 1,
                 IOLink.ImageView outputGrayImage = null );

Class Syntax

Parameters

Class Name GetColorChannel

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

Object Examples

std::shared_ptr< iolink::ImageView > 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

std::shared_ptr< iolink::ImageView > 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() );